#include<stdio.h>

int main(void){
    
    int X;
    int N;
    int p[1000];
    int i;
    int dir=1;
    int tmp;
    int cnt=1;
    int loop=2;

    scanf("%d %d", &X, &N);
    tmp = X;

    if(N==0){
        printf("%d", X);
        return 0;
    }

    for(i=0; i<N; i++){
        scanf("%d", &p[i]);
    }

    while(cnt!=0){
        
        cnt = 0;

        for(i=0; i<N; i++){
            if(tmp==p[i] && dir==1){
                tmp = X - loop / 2;
                dir = -1;
                cnt++;
                break;
            }
            if(tmp==p[i] && dir==-1){
                tmp = X + (loop-1) / 2;
                dir = 1;
                cnt++;
                break;
            }
        }
        loop++;
    }
    
    printf("%d", tmp);

    return 0;
}