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

int main(){
  int x, n, a, b, i, j, judge=0;
  scanf("%d %d", &x, &n);
  int p[n];

  for(j=0; j<n; j++)
    scanf("%d", &p[j]);

  i=x;
  while(1){
    for(j=0; j<n; j++){
      if(i==p[j]){
        judge=1;
        break;
      }
    }
    if(judge==0){
      a=i;
      break;
    }
    judge=0;
    i--;
  }

  i=x;
  while(1){
    for(j=0; j<n; j++){
      if(i==p[j]){
        judge=1;
        break;
      }
    }
    if(judge==0){
      b=i;
      break;
    }
    judge=0;
    i++;
  }

  if(fabs(x-a)<=fabs(b-x))
    printf("%d\n", a);
  else
    printf("%d\n", b);

  return 0;
}
