#include <stdio.h>
#include <stdlib.h>
int main(){
  int a[200];
  int b,c,i,j,tmp,tmp2;
  scanf("%d %d",&b,&c);
  for(i=0;i<c;i++){
    scanf("%d",a[i]);
  }
   for (i=0; i<c; ++i) {
    for (j=i+1; j<c; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  for (i=0; i<c; ++i) {
    for (j=i+1; j<c; ++j) {
      if(abs(b-a[i]) > abs(b-a[j])){
       tmp2 =  a[i];
        a[i] = a[j];
        a[j] = tmp2;
      }
    }
  } 
  for(i=0;i<c;i++){
    if(abs(b-a[i] != 0){
      printf("%d",a[i]);
      break;
    }
  }
  return 0;
  }