#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
  int x,n;
  cin>>x>>n;
  if(n==0)
    cout<<x;
  else
  {
    vector <int> p;
    vector <int> ne;
    int a;
    for(int i=1;i<=n;i++)
    {
      cin>>a;
      if(a>=x)
      {p.pb(a-x);}
      else
      {ne.pb(x-a);}
    }
    int n1,n2;
    sort(p.begin(),p.end());
    sort(ne.begin(),ne.end());
    for(int i=0;i<p.size();i++)
    {
      if(p[i]!=i)
      {n1=i;break;}
      if(i==(p.size()-1) && p[i]==i)
      {n1=i+1;}
    }
    for(int i=0;i<ne.size();i++)
    {
      if(ne[i]!=(i+1))
      {n2=i+1;break;}
      if(i==(ne.size()-1) && ne[i]==(i+1))
      {n2=i+2;}
    }
    if(n1==n2)
      cout<<x-n2;
    else if(n1<n2)
      cout<<x+n1;
    else
      cout<<x-n2;
  }
}