#include<bits/stdc++.h>
using namespace std;

int main()
{
	unordered_map<int,int> m;
	int n,x;
	cin>>x>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	int t=x;
	while(m.find(t)!=m.end())
		t--;
	int ans=t;
	t=x;
	while(m.find(t)!=m.end())
		t++;
	if(t-x<x-ans)
		ans=t;
	cout<<ans;
	return 0;
}