///S->----------------------------------------------------|
///R->--------------</AUTHOR - SRIJAN DE>-----------------|
///I->--------</https://thesrijande.github.io/>-----------|
///J->----</JALPAIGURI GOVERNMENT ENGINEERING COLLEGE>----|
///A->------------</INFORMATION TECHNOLOGY>---------------|
///N->----------------------------------------------------|
#include    <bits/stdc++.h>
using       namespace            std;
using       ll =                 int64_t ;
using       ull =                unsigned long long ;
using       ld =                 long double;
#define     int                  int64_t
#define     mem(a,val)           memset( a,  val,  sizeof(a) )
#define     b_s                  binary_search
#define     u_b                  upper_bound
#define     l_b                  lower_bound
#define     nl                   cout<<endl
#define     pb                   push_back
#define     pf                   push_front
#define     ppb                  pop_back
#define     ppf                  pop_front
#define     in                   insert
#define     fi                   first
#define     se                   second
#define     umap                 unordered_map
#define     pqueue               priority_queue
#define     rr                   return
#define     bits(n)              __builtin_popcount(n)
const int   N =                   1e6 + 7;
const int   MOD =                 (int)1e9 + 7;
const int   MOD1 =                (int)1e9 + 9;
const int   MOD2 =                998244353;
const ld    pi =                  atan2(0, -1);
const ld    eps =                 1e-9;
int         tests =               1;
template<class x, class y>x max(x a, y b) {
    return (a > b) ? a : b;
}
template<class x, class y>x min(x a, y b) {
    return (a < b) ? a : b;
}
template<class x, class y>x log(x n, y r) {
    return (n > r - 1) ? 1 + log(n / r, r) : 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'
vector<int> adj[N], subset;
int vis[N] = {0};
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main()
{
    auto start = clock();
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    }
#endif
//  cout<<fixed;
//  cout<<scientific;
//  cout<<fixed<<setprecision(12);
    // cin >> tests;
    for (int test = 1; test <= tests; test++)
    {
        // cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'   .'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
        int n, x;
        cin >> x >> n;
        if (n == 0)
        {
            cout << x;
            rr 0;
        }
        int a[n], h[1000] = {0};
        int mn = 1000000000;
        int ans = 1000000000;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            h[a[i]] = 1;
        }
        for (int i = x; i <= 1001; i++)
        {
            if (h[i] == 0)
            {
                mn = abs(x - i);
                ans = min(ans, i);
                break;
            }
        }
        for (int i = x; i >= 0; i--)
        {
            if (h[i] == 0)
            {
                if (mn >= abs(x - i))
                    ans = min(ans, i);
                break;
            }
        }
        cout << ans;




///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.

    }
    cerr << endl << endl <<  endl <<
         "Time : " << double(clock() - start) / CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 27276