#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
    ifstream fi("ganmnhat.inp");
    long int n,m;
    fi>>n>>m;
    long int a[n],b[n];
    long int k=0,g=0;
    for(long int i=0;i<n;i++)
    {
        fi>>a[i];
    }
    long int tg;
    for(long int i=0;i<n-1;i++)
        for (long int j=1;j<n;j++)
            if(a[i]>a[j])
            {
                tg=a[i];
                a[i]=a[j];
                a[j]=tg;
            }
    b[0]=abs(m-a[0]);
    for(long int i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            b[i]=-1;
        }
        else
        {
            b[i]=abs(m-a[i]);
        }
    }
    long int min=b[0];
    for(long int i=1;i<n;i++)
    {
        if(b[i]!=-1)
        {
            if(min>b[i])
            {
                min=b[i];
                k=i;
            }
        }
    }
    fi.close();
    ofstream fo("ganmnhat.out");
    fo<<a[k];
}
