#include<stdio.h>
int main(){
  int p[110],m[110],x,n,t,i;
  scanf("%d%d",&x,&n);
  for(i=0;i<110;i++)p[i]=m[i]=1;
  for(i=0;i<n;i++){scanf("%d",&t);if(x<t)p[t-x]=0;else if(x>t)m[x-t]=0;else p[0]=m[0]=0;}
  for(i=0;i<n;i++){if(m[i]){printf("%d",x-i);return 0;}if(p[i]){printf("%d",x+i);return 0;}}
}
