#include <fstream>
#include<cmath>
using namespace std;
int main()
{

    int a[100000],n,i,k,h,t;
    long long M;
    ifstream fi;
    fi.open("GANMNHAT.INP");
    fi>>n>>M;
    for(i=0;i<n;i++)
    {
        fi>>a[i];
    }
    fi.close();
    ofstream fo;
    fo.open("GANMNHAT.OUT");
    k=abs(M-a[0]),t=a[0];
    for(i=1;i<n;i++)
    {
        h=abs(M-a[i]);
        if (k>h){k=h;t=a[i];}
        if (k==h){if(a[i]<t){t=a[i];}}
        if (h==0){t=a[i];break;}
		}

    
    fo<<t;
}

