#include <iostream>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <climits>
#include <stdlib.h>
#define mp make_pair
#define pb push_back
#define forn(n) for(long long i=0;i<n;++i)

#define ll long long
#define ull unsigned long long
#define mod 1000000007
typedef long double ld;
using namespace std;




vector<ll> sieve(ll n)
{
	vector<ll> a(n+1,0);
	for(ll i=3;i<=n;i+=2)
	a[i]=1;
	for(ll i=3;i<=n;i+=2)
	{
       if(a[i]==1)
	   {
		   for(ll j=i*2;j<=n;j+=i)
		   a[j]=0;
	   }
	}
	a[2]=1;
	a[1]=a[0]=0;
	return a;
}
ll reverse(ll n)
{
	ll s=0;
	while(n>0)
	{
       ll t=n%10;
	   s=s*10+t;
	   n/=10;
	}
	return s;
}
int count_setbits(int N)

{ int cnt=0;

while(N>0)

{

cnt+=(N&1);

N=N>>1;

}

return cnt;

}
ll power(ll x, ll y)  
{  
    int res = 1;     // Initialize result  
  
    x = x % mod; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % mod;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % mod;  
    }  
    return res;  
}  

void BellmanFord(vector< vector<ll> > &graph, int V, int E, int src) 
{ 
    // Initialize distance of all vertices as infinite. 
    int dis[V]; 
    for (int i = 0; i < V; i++) 
        dis[i] = INT_MAX; 
  
    // initialize distance of source as 0 
    dis[src] = 0; 
  
    // Relax all edges |V| - 1 times. A simple 
    // shortest path from src to any other 
    // vertex can have at-most |V| - 1 edges 
    for (int i = 0; i < V - 1; i++) { 
  
        for (int j = 0; j < E; j++) { 
            if (dis[graph[j][0]] + graph[j][2] < 
                               dis[graph[j][1]]) 
                dis[graph[j][1]] =  
                  dis[graph[j][0]] + graph[j][2]; 
        } 
    } 
  
    // check for negative-weight cycles. 
    // The above step guarantees shortest 
    // distances if graph doesn't contain 
    // negative weight cycle.  If we get a 
    // shorter path, then there is a cycle. 
    for (int i = 0; i < E; i++) { 
        int x = graph[i][0]; 
        int y = graph[i][1]; 
        int weight = graph[i][2]; 
        if (dis[x] != INT_MAX && 
                   dis[x] + weight < dis[y]) 
            cout << "Graph contains negative"
                    " weight cycle"
                 << endl; 
    } 
  
    
} 
ll globd=INFINITY;
ll minimum(vector<pair<ll,int> >tmp)
{

}


void f(vector<ll> p,vector<ll> a,vector<pair <ll,int> >tmp,int choice)
{
    if(tmp.size()>=3)
    {
        globd=minimum(tmp);
    }
    ll d=a[choice]-p[choice];
    tmp.push_back(make_pair(d,1));
    return f(p,a,tmp,choice+1);
    tmp.pop_back();
    if(p[choice]!=0)
    {
        if(a[choice]%p[choice]==0)
        {
            ll x=a[choice]/p[choice];
            tmp.push_back(make_pair(x,0));
            return f(p,a,tmp,choice+1);

        }
    }
}

ll no_of_pairs(vector<ll> &a,vector<ll> &b,ll n)
{
    ll res=0;
    forn(n)
    {
        if(a[i]==b[i])
        res++;
    }
    return res;
}
char ch[1001][1001];
bool vis[1001][1001];
bool isValid(int i,int j,int n,int m)
{
    if(i<1 || i>n || j<1 || j>m)
    return false;
    if(ch[i][j]=='#' || vis[i][j]==true)
    return false;
    return true;
}
void dfs(int i,int j,int n,int m)
{
    vis[i][j]=true;
    //cout<<i<<" "<<j<<"\n";
    if(isValid(i,j-1,n,m)) //up
    dfs(i,j-1,n,m);
    if(isValid(i-1,j,n,m)) //left 
    dfs(i-1,j,n,m);
    if(isValid(i+1,j,n,m)) //down
    dfs(i+1,j,n,m);
    if(isValid(i,j+1,n,m)) //right
    dfs(i,j+1,n,m);
}
bool pair_helper(pair<ll,ll> a,pair<ll,ll> b,pair<ll,ll> c) {
    if(c.first==0 || c.second%c.first!=0)
    return false;
    else
    {
        ll res=c.second/c.first;
        if (res==0)
        return false;
        else
        {
            if(a.second%res!=0 || b.second%res!=0)
            return false;
            else
            {
                if(a.second/res-a.first!= b.second/res-b.first)
                return false;
                else
                {
                    return true;
                }
                
            }
        }
        
    }
    
}
bool pairwise_possible(pair<ll,ll> a, pair<ll,ll> b,pair<ll,ll> c)
{
    bool ans=0;
    ans=pair_helper(a,b,c);
    if(ans==1)
    return true;
    ans=pair_helper(a,c,b);
    if (ans==1)
    {
       return true;
    }
    ans=pair_helper(b,a,c);
    if(ans==1)
    return true;
    ans=pair_helper(b,c,a);
    if(ans==1)
    return true;
    ans=pair_helper(c,a,b);
    if(ans==1)
    return true;
    ans=pair_helper(c,b,a);
    if(ans==1)
    return true;
    return false;


    
}

bool answer_is_one(pair<ll,ll> a, pair<ll,ll> b,pair<ll,ll> c)
{
    if(a.second%a.first==0 && b.second%b.first==0 && c.second%c.first==0)
    {
        cout<<a.second/a.first<<" "<<b.second/b.first<<" "<<c.second/c.first<<" 100000\n";
        if((a.second/a.first)==(b.second/b.first)==(c.second/c.first))
        return true;
    }
    if(a.second-a.first==b.second-b.first==c.second-c.first)
    return true;
    if(a.first==a.second)
    {
        if(b.second%b.first==0 && c.second%c.first==0)
        {
            if(b.second/b.first==c.second/c.first)
            return true;
        }
        if(b.second-b.first==c.second-c.first)
        return true;
    }
    if(b.first==b.second)
    {
        if(a.second%a.first==0 && c.second%c.first==0)
        {
            if(a.second/a.first==c.second/c.first)
            return true;
        }
        if(a.second-a.first==c.second-c.first)
        return true;
    }
    if(c.first==c.second)
    {
        if(b.second%b.first==0 && a.second%a.first==0)
        {
            if(b.second/b.first==a.second/a.first)
            return true;
        }
        if(b.second-b.first==a.second-a.first)
        return true;
    }
    if(a.first==a.second && b.first==b.second)
    {
        return true;
    }
    if(a.first==a.second && c.first==c.second)
    {
        return true;
    }
    if(c.first==c.second && b.first==b.second)
    {
        return true;
    }
   


    return false;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   ll x,n;cin>>x>>n;
   set<ll> st;
   forn(n)
   {
       ll tmp;cin>>tmp;st.insert(tmp);
   }
   ll copy1=x;
   while(st.find(copy1)!=st.end())
   copy1++;
   ll copy2=x;
   while(st.find(copy2)!=st.end())
   copy2--;
   //cout<<copy1<<" "<<copy2<<"\n";
   if((x-copy2)<(copy1-x))
   cout<<copy2<<"\n";
   else if((x-copy2)>(copy1-x))
   cout<<copy1<<"\n";
   else
   {
       cout<<min(copy1,copy2)<<"\n";
   }
   

    




}

Measured memory_bytes: 3664