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

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

int binarySearch(int arr[], int l, int r, int x) 
{ 
    while (l <= r) { 
        int m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        else if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    } 
    return -1; 
}

int main(void) {
  int X, N;
  scanf("%d %d", &X, &N);
  int p[N], i;
  for(i = 0; i < N; ++i)
    scanf("%d", &p[i]);
  int b, a, min = 100, ans = 0, absolute;
  qsort(p, N, sizeof(int), comfun);
  for(i = 1; i <= p[N - 1]; ++i){
    b = binarySearch(p, 0, N - 1, i);
    if(b == -1){
      a = X - i;
      absolute = abs(a);
      if(absolute < min){
        min = absolute;
        ans = i;
      }
    }
    else 
      continue;
  }
  printf("%d\n", ans);
  return 0;
}