#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

//VECTOR & STRING & PAIR
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define del(v,i,j) v.erase(v.begin() + i, v.begin() +j + 1)
#define pb push_back
#define sz(v) (ll)v.size()
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second




//NUMBER THEORY
#define MAX 000000
#define pi acos(-1.0)
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
vector<ll> prime;
bitset<MAX + 1> isPrime;
vector<ll> primeFactor;
vector<ll> uniqueprimeFactor;
vector<ll> divisors[MAX + 1];
vector<ll> divNum;
ll phiValue[MAX + 1];
void seive(ll lim);
void primeFactorial(ll n);
void eulerPhi(ll lim);
void divGenerator(ll n);
void div(ll n);
ll bigMod(ll b, ll p, ll m);
ll nCr(ll n, ll r);
ll string2int(string str);
string int2string(ll num);



//DATA STRUCTURE & ALGORITHMS
ll bs(ll arr[],ll l, ll r, ll x);
ll prevMatch(ll arr[], ll l, ll r, ll x);
ll range(ll arr[], ll l, ll r, ll left,ll right);
ll firstMarched (ll arr[], ll l, ll r, ll x);

ll vbs(vector <ll> arr,ll l, ll r, ll x);
ll vprevMatch(vector <ll> arr, ll l, ll r, ll x);
ll vrange(vector <ll> arr, ll l, ll r, ll left,ll right);
ll vfirstMarched (vector <ll> arr, ll l, ll r, ll x);


/*███╗   ██╗ █████╗ ██████╗ ██╗██╗         ███╗   ███╗ █████╗ ███████╗██╗  ██╗██████╗ ██╗███████╗███████╗
  ████╗  ██║██╔══██╗██╔══██╗██║██║         ████╗ ████║██╔══██╗██╔════╝██║  ██║██╔══██╗██║██╔════╝██╔════╝
  ██╔██╗ ██║███████║██████╔╝██║██║         ██╔████╔██║███████║███████╗███████║██████╔╝██║█████╗  █████╗
  ██║╚██╗██║██╔══██║██╔══██╗██║██║         ██║╚██╔╝██║██╔══██║╚════██║██╔══██║██╔══██╗██║██╔══╝  ██╔══╝
  ██║ ╚████║██║  ██║██████╔╝██║███████╗    ██║ ╚═╝ ██║██║  ██║███████║██║  ██║██║  ██║██║███████╗██║
  ╚═╝  ╚═══╝╚═╝  ╚═╝╚═════╝ ╚═╝╚══════╝    ╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚══════╝╚═╝*/

int main()
{
    fastio;
    ll x,n;
    cin>>x>>n;
    if(n==0)
    {
			cout<<x<<endl;
			return 0;
		}
    ll a[n];
    for(ll i=0;i<n;++i)
    {
			cin>>a[i];
		}
		sort(a,a+n);
		vector<ll> v;
		v.pb(a[0]-1);
		for(ll i=0;i<n-1;++i)
		{
			if(a[i+1]-a[i]>1)
			{
				for(ll j=a[i]+1;j<a[i+1];j++)
				{
					v.pb(j);
				}
			}
		}
		v.pb(a[n-1]+1);
		ll ans1,ans2;
		ans1=v[vprevMatch(v,0,sz(v)-1,x)];
		ans2=v[vprevMatch(v,0,sz(v)-1,x)+1];
		if(abs(x-ans1)>abs(x-ans2))
		{
			cout<<ans2<<endl;
		}
		else
		{
			cout<<ans1<<endl;
		}
    return 0;
}


//GCD
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}
//LCM
ll lcm(ll a, ll b)
{
    ll ret=((a/gcd(a,b))*b);
    return ret;
}
//SEIVE
void seive(ll lim)
{
    isPrime.set();
    prime.pb(2);
    for (ll i = 3; i <= lim; i += 2)
    {
        if (isPrime[i])
        {
            prime.pb(i);
            for (ll j = i * i; j <= lim; j += (i << 1))
            {
                isPrime[j] = 0;
            }
        }
    }
}
//PRIME FACTORIAL
void primeFactorial(ll n)
{
    for (ll i = 0; prime[i] * prime[i] <= n; i++)
    {
        ll cnt=0;
        while (n % prime[i] == 0)
        {
            n = n / prime[i];
            cnt++;
            primeFactor.pb(prime[i]);
        }
        if(cnt>0)
        {
            uniqueprimeFactor.pb(prime[i]);
        }
        if (n == 1)
        {
            break;
        }
    }
    if (n > 1)
    {
        primeFactor.pb(n);
        uniqueprimeFactor.pb(n);
    }
}
//EULER SEIVE
void eulerPhi(ll lim)
{
    for (ll i = 0; i <= lim; ++i)
    {
        phiValue[i] = i;
    }
    for (ll i = 2; i <= lim; ++i)
    {
        if (phiValue[i] == i)
        {
            for (ll j = i; j <= lim; j += i)
            {
                phiValue[j] = (phiValue[j] * (i - 1)) / i;
            }
        }
    }
    phiValue[0] = 1;
    phiValue[1] = 1;
}
//BIG MOD
ll bigMod(ll b, ll p, ll m)
{
    ll y;
    if (b == 0)
    {
        return 0;
    }
    if (p == 0)
    {
        return 1;
    }
    if (p % 2 == 0)
    {
        y = bigMod(b, p / 2, m);
        y = (y * y) % m;
    }
    else
    {
        y = b % m;
        y = (y * bigMod(b, p - 1, m) % m) % m;
    }
    return (y + m) % m;
}
//NCR
ll nCr(ll n, ll r)
{
    ll p = 1, k = 1;
    if (n - r < r)
    {
        r = n - r;
    }
    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;
            ll m = gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
    {
        p = 1;
    }
    return p;
}
//DIVISOR GENERATOR
void divGenerator(ll n)
{
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = i; j <= n; j += i)
        {
            divisors[j].pb(i);
        }
    }
}
//STRING TO INT
ll string2int(string str)
{
    ll cnt=1,sum=0;
    for(ll i=str.length()-1; i>=0; i--)
    {
        ll typcast=(int)(str[i])-48;
        sum=sum+typcast*cnt;
        cnt=cnt*10;
    }
    return sum;
}
//INT TO STRING
string int2string(ll num)
{
    string str="";
    while(num>0)
    {
        int ch;
        ch=((num)%10)+48;
        str+=char(ch);
        num=num/10;
    }
    rev(str);
    return str;
}
//DIVISOR OF A NUM
void div(ll n)
{
    for(ll i=1; i*i<=n; ++i)
    {
        if(n%i==0)
        {
            if(i!=(n/i))
            {
                divNum.pb(i);
                divNum.pb(n/i);
            }
            else
            {
                divNum.pb(i);
            }
        }
    }
    srt(divNum);
}
// BINARY SEARCH
ll bs(ll arr[],ll l, ll r, ll x)
{
    ll m;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] == x)
        {
            return m;
        }
        else if (arr[m] < x)
        {
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return -1;
}
ll vbs(vector <ll> arr,ll l, ll r, ll x)
{
    ll m;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] == x)
        {
            return m;
        }
        else if (arr[m] < x)
        {
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return -1;
}
//PREVIOUS OR MATCHED ELEMENT INDEX
ll prevMatch(ll arr[], ll l, ll r, ll x)
{
    ll  m, ret = -1;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] <= x)
        {
            ret = m;
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return ret;
}
ll vprevMatch(vector <ll> arr, ll l, ll r, ll x)
{
    ll  m, ret = -1;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] <= x)
        {
            ret = m;
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return ret;
}
//FIND SEGMENT LENGTH
ll range(ll arr[], ll l, ll r, ll left,ll right)
{
    ll ret;
    ret=prevMatch(arr,l,r,right)-prevMatch(arr,l,r,left-1);
    return ret;
}
ll vrange(vector <ll> arr, ll l, ll r, ll left,ll right)
{
    ll ret;
    ret=vprevMatch(arr,l,r,right)-vprevMatch(arr,l,r,left-1);
    return ret;
}
//VERY FIRST MATCHED ELEMENT INDEX
ll firstMarched (ll arr[], ll l, ll r, ll x)
{
    ll  m, ret = -1;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] == x)
        {
            ret = m;
            r = m - 1;
        }
        else if (arr[m] < x)
        {
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return ret;
}
ll vfirstMarched (vector <ll> arr, ll l, ll r, ll x)
{
    ll  m, ret = -1;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (arr[m] == x)
        {
            ret = m;
            r = m - 1;
        }
        else if (arr[m] < x)
        {
            l = m + 1;
        }
        else
        {
            r = m - 1;
        }
    }
    return ret;
}



Measured memory_bytes: 3616