#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int cmp_int(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void) {
  int x, n;
  scanf("%d %d", &x, &n);
  int num[n];
  if (!n) {
    printf("%d\n", x);
  } else {
    for (int i = 0; i < n; i++) {
      scanf(" %d", &num[i]);
    }

    qsort(num, n, sizeof(int), cmp_int);

    for (int i = 0; i < n; i++) {
      if (x < num[i]) {
        printf("%d\n", x);
        break;
      } else if (x > num[i]) {
        continue;
      } else if (x == num[i]) {
        int low = x - 1;
        int high = x + 1;

        for (int j = i - 1; j > -1; j--) {
          if (low != num[j]) {
            break;
          }
          low--;
        }

        for (int j = i + 1; j < n; j++) {
          if (high != num[j]) {
            break;
          }
          high++;
        }

        if ((x - low) > (high - x)) {
          printf("%d\n", high);
          break;
        } else {
          printf("%d\n", low);
          break;
        }
      }
    }
  }

  return 0;
}
