/*
Mangal bhavan amangal haari
Drabahu su Dasharath achar Bihari
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hoi hai wohi jo Raam rachi raakha
Ko kari tarak badhave saakha
Raam Siya Raam Siya Raam jai jai Raam
Ho dheeraj dharam mitra aru naari
Aapad kaal parakhiye chaari
Ho jehike jehi par satya sanehu
So tehi milay na kachhu sandehu
Ho jaaki rahi bhawana jaisi
Prabhu murati dekhi tin taisi
Ho Raghukul reet sada chali aayi
Praan jaaye par vachan na jaayi
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hari anant hari katha ananta
Kahahi sunahi bahuvidhi sab santa
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i
vector<int> sieve(int n) 
{ 

    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = sqrt(n); 
   vector<int> ans;

    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    //vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i); 
    return ans; 
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a ;//% mod;
		a = 1LL * a * a ;//% mod;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
ll myXOR(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}
int conti(int x)
{
	if(x<1)
	return 0;
	if(x%4==0)
	return x;
	if(x%4==1)
	return 1;
	if(x%4==2)
	return x+1;
	if(x%4==3)
	return 0;
}
  
bool ispfsq(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}
#define PI 3.141592653589793
void solve()
{
int n,x;
cin>>x>>n;
int arr[n+3];
map<int,int> m;
for(int i=0;i<n;i++)
{
	cin>>arr[i];
     m[arr[i]]++;
}
int t=x,ans,mi;
while(1)
{
	if(m.find(t)==m.end())
	{
		ans=t;
		mi=abs(x-t);
		break;
	}
	else
	t--;
}
t=x;
int a,ma;
while(1)
{
	if(m.find(t)==m.end())
	{
		a=t;
		ma=abs(t-x);
		break;
	}
	else
	t++;
}
if(mi<=ma)
{
	cout<<ans;
	return;
}
else
{
	cout<<a;
	return ;
	}	


 
}
/*void dfs(vector<int> adj[],bool visited[],int a)
{
	if(visited[a]==false)
	visited[a]=true;
	else
	return ;
	for(int i=0;i<adj[a].size();i++)
	{
	
		if(!visited[adj[a][i]])
		{
	dcost[adj[a][i]]=min(cost[a],dcost[a]);
	dfs(adj,visited,adj[a][i]);
	    }
	}
	}*/
	
	


/*int dfs(vector<int> adj[],int v,int c,int p)
{
//	cout<<p<<" "<<v<<" "<<c<<"\n";
	c+=arr[v];
	if(c>m)
	{
	return 0;
    }
	if(adj[v].size()==1&&v!=1)
	return 1;
	int a=0;
	for(int i=0;i<adj[v].size();i++)
	{
		if(adj[v][i]!=p)
		{
			
			int x=dfs(adj,adj[v][i],c*arr[adj[v][i]],v);
			a+=x;
		}
	}
	return a;
}
*/

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//func();
int mul=0;
if(mul==1)
{
 int t;
 
    cin>>t;
   while(t--)
    {
		solve();
	cout<<"\n";
    }
}
else
{
	solve();
}
}

Measured memory_bytes: 3684