Problem:
Score : 300 points

Problem Statement

Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.

Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

1 \leq X \leq 100

0 \leq N \leq 100

1 \leq p_i \leq 100

p_1, \ldots, p_N are all distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X N
p_1 ... p_N

Output

Print the answer.

Sample Input 1

6 5
4 7 10 6 5

Sample Output 1

8

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.

Sample Input 2

10 5
4 7 10 6 5

Sample Output 2

9

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.

Sample Input 3

100 0

Sample Output 3

100

When N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

/***
        ***Fresher***
    Md Mahfujur Rahman Khan(So..a;)
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

    FSTREAM

***/
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<array>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
/***PAIR***/
#define pll pair<ll,ll>
#define pcl pair<char,ll>
#define psl pair<string, ll>
#define pls pair<ll,string>
#define plc pair<ll, char>
/***MAP***/
#define mll map<ll,ll>
#define msl map<string, ll>
#define mls map<ll, string>
#define mlb map<ll,bool>
#define msb map<string,bool>
#define mcl map<char, ll>
/***VECTOR***/
#define vl vector<ll>
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define IT_ ::iterator
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(v,x) v.push_back(x)
#define PP(x) push(x)
#define RSZ(a , n) a.resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN(s,cst) (cst)s.length()
#define SZ(s, a) (ll)s.size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN(s, a) s.insert(a)
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int


/***
//bit prime
#define most_prime_loop 1001
#define most_prime_number 1000010
#define prime_MAX_arr 1000010/64 +1
ll PRIME[prime_MAX_arr];
void Set(ll n)
{
    ll m= n%64;
    n/=64;
    ll x = 1;
    x <<=m;
    PRIME[n] |=x;
    return ;
}
bool check(ll n)
{
    if(n==2) return true;
    if(n%2==0) return false;
    ll m= n%64;
    n/=64;
    ll x = 1;
    x <<=m;

    return !(x&PRIME[n]);

}
void seivee()
{
    fa(x, PRIME)x = 0;
    Set(2);
    for(ll i= 3; i <=most_prime_loop; i+=2)
    {
        if(check(i))
        {
            for(ll j = i*i; j <=most_prime_number; j+=i)
            {
                Set(j);
            }
        }
    }

}

***/

#define fr(i ,a,  n) for( ll i = a; i <= n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)
#define SRT(s)   sort(s.B_, s.E_)
#define TEST      ll test; cin >> test; while(test--)

#define pi acos(-1)

#define SR(x,a) (a)sqrt(x)

#define IC   (ll)
#define CMP compare
//#define mod 1000000007
#define all(v) v.B_,v.E_
#define rall(v) v.rbegin(),v.rend()

#define mod(a) a%1000000007
#define lcm(a, b) (a/__gcd(a,b))*b
#define INT(dp, v) memset(dp,v, sizeof(dp))





int main()
{
    ll n;
    map<ll, ll> mp;
    ll x;
    cin >> x;
    cin >> n;
    fe(1, n)
    {
        ll r;
        cin >> r;
        mp[r];
    }
    ll i=0;
    while(1)
    {
        if(mp.count(x-i)==0)
        {
            cout << x-i;
            break;
        }
        if(mp.count(x+i)==0)
        {
            cout << x+i;
            break;
        }
        i++;
    }

    R_0;
}