#include <bits/stdc++.h>

using namespace std;

int main()
{
    unsigned long long n,k;
    unsigned long long m;
    cin>>n>>k;
    unsigned long long a[20000];
    for(unsigned long long i=0;i<n;i++){
        cin>>a[i];
        if(k==a[i])m=i;
    }
    unsigned long long r;
    if(m==n-1)r=a[0];
    else r=a[m+1];
    cout<<r;


    return 0;
}