#include<stdio.h>
#include<stdlib.h>
int minof(int x, int y, int base)
{
    if (abs(x - base) < abs(y - base))
        return (x);
    else
        return (y);
}

int main()
{
        int min_tmp_ans;
        int max_tmp_ans;
    int *p_arr;
    int *p_arr_over;
    int  arr[101];
    int i;
    int x, n;
    int tmp_ans, min_dif, tmp_over;

    // 整数の入力
    p_arr = arr;
    scanf("%d %d", &x, &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", p_arr);
        p_arr++;
    }
    *p_arr = '\0';

    //sort
    int l,j,tmp;
    for (l=0; l<n; ++l) {
    for (j=l+1; j<n; ++j) {
      if (arr[l] > arr[j]) {
        tmp =  arr[l];
        arr[l] = arr[j];
        arr[j] = tmp;
      }
    }
  }

    p_arr = arr;
    min_dif = 101;
    if (n == 0)
    {
        tmp_ans = x;
    }
    else
    {
        for (i = 0; i < n; i++)
        {
            if (arr[i] >= x)
            {
                p_arr_over = &arr[i];
                tmp_over = arr[i];
                break;
            }
        }
        while (1)
        {
            if(tmp_over - 1 != x && *p_arr_over-1 != tmp_over - 1)
            {
                min_tmp_ans = tmp_over -1;
                break;
            }
            tmp_over = tmp_over -1;
            p_arr_over = p_arr_over -1;
        }
        p_arr_over = &arr[i];
        tmp_over = arr[i];
        while (1)
        {
            if(tmp_over + 1 != x && *p_arr_over+1 != tmp_over + 1)
            {
                max_tmp_ans = tmp_over +1;
                break;
            }
            tmp_over = tmp_over +1;
            p_arr_over = p_arr_over +1;
        }

//printf("tmp_ans:%d min_dif:%d p_arr:%d", tmp_ans, min_dif, *p_arr);
//        for (i = 0; i < n; i++)
 //       {
   //         if (abs(*p_arr - x) < min_dif && *p_arr != x)
     //       {
       //         min_dif = abs(*p_arr - x);
         //       tmp_ans = *p_arr;
           // }
            //p_arr++;

       //}
    }
   printf("%d", minof(min_tmp_ans, max_tmp_ans, x));
    return 0;
}