#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v, ch;
  vector<pair<int, int> > mp;
  bool have = false;
  int x, n;
  cin >> x >> n;
  int ara[n];
  for (int i = 0; i < n; i++) {
    cin >> ara[i];
    if (ara[i] == x) have = true;
  }
  sort(ara, ara + n);
  if (!have)
    cout << x << endl;
  else {
    int j = 0, sz = v.size();
    for (int i = 0; i <= n + 8; i++) {
      v.push_back(i);
    }
    for (int i = 0; i < sz; i++) {
      if (ara[j] == v[i])
        j++;
      else
        ch.push_back(v[i]);
    }
    int l = ch.size();
    for (int i = 0; i < l; i++) {
      mp.push_back(make_pair(abs(ch[i] - x), ch[i]));
    }
    sort(mp.begin(), mp.end());
    cout << mp[0].second << endl;
  }
  return 0;
}
