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

int cmpnum(const void *n1,const void *n2){
  if(*(int *)n1 > *(int *)n2)
    return -1;	
  else if (*(int *)n1 < *(int *)n2)
    return 1;
  else
    return 0;
}

int main(){
  int x,n;
  int sa = 1000,min,minnum,right,left;
  int i,f1=0,f2=0;
  scanf("%d %d",&x,&n);
  if(n==0){
    printf("%d",x);
    exit(0);
  }
  int p[n];
  for(i=0;i<n;i++)
    scanf("%d",&p[i]);
  qsort(p,sizeof(p)/sizeof(p[0]),sizeof(int),cmpnum); //降順に並べ替える
  //printf("%d %d %d %d\n",p[0],p[1],p[2],p[3]);
  
  for(i=0;i<n;i++){
    if(abs(x-p[i]) <= sa){
      min=p[i];
      minnum=i;
      sa=abs(x-p[i]);
    }
  }
  //printf("min:%d minnum:%d\n",min,minnum);
  for(i=0;i<n-minnum;i++){
    //printf("r  %d %d\n",p[minnum+i],p[minnum]-i);
    if(p[minnum+i] != p[minnum]-i){
      right = p[minnum]-i;
      f1++;
      i=n-minnum-1;
    }
  }
  if(f1==0)
    right=p[n-1]-1;
  for(i=0;i<minnum+1;i++){
    //printf("l  %d %d\n",p[minnum-i],p[minnum]+i);
    if(p[minnum-i] != p[minnum]+i){
      left = p[minnum]+i;
      f2++;
      i=minnum;
    }
  }
  if(f2==0)
    left=p[0]+1;
  //printf("l:%d r:%d\n",left,right);
  if(abs(x-right) > abs(x-left))
    printf("%d",left);
  else if(abs(x-right) == abs(x-left))
    printf("%d",right);
  else
    printf("%d",right);
}