#include <iostream>
#include <iomanip>

using namespace std;

void unos(unsigned a[],int n)
{
    for(int i=0;i<n;i++)
        cin>>a[i];
}

int karta(unsigned a[],int n,int k)
{
    int l=0,r=n-1,m;
    if(k==a[n-1])
        return a[0];
    else
    {while(l<=r)
    {
        m=l+(r-l)/2;
        if(a[m]==k)
        {
                return a[m+1];

        }

        if(k>a[m])
            l=m+1;
        if(k<a[m])
            r=m-1;
    }}
}

int main()
{
    ios::sync_with_stdio(false);
    unsigned n,k;
    cin>>n>>k;
    unsigned a[n];
    unos(a,n);
    cout<<karta(a,n,k);

    return 0;
}