#include<stdio.h>

int main(void){

    int X, N,min=100, ans,j=1;
    int p[100], temp[100];
    temp[0] = 100;
    scanf("%d %d", &X, &N);

    if(N==0){
        printf("%d",X);
    }
    else{
        for(int i=0;i<N;i++){
            scanf("%d", p[i]);
            ans=abs(X-p[i]);
            if(min>=ans){
                min=ans;
                temp[j] = p[i];
                if(temp[0]>temp[j]){
                    temp[0]=temp[j];
                }
                j++;
            }
        }
        printf("%d", temp[0]);

    }

    return 0;
}