selecting numbers with a potmeter

Create an array, then upon reading a button press you take an analogRead() and place the number in the array.

byte selectedNumber[4];
byte counter = 0;
void loop() {
  if (digitalRead(BUTTON_PIN) == LOW) {
    int x = analogRead(A0);
    selectedNumber[counter] = map(x, pMin, pMax, 0, 24);
    counter++;
    delay(100); // for button bounce
  }
  if (counter >= 4) {
    do_check_code();
  }
}