#include <bits/stdc++.h>
using namespace std;

int a[200005];

int main()
{
    int n, k;
    cin >> n >> k;
    int p;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(k == a[i]){
            p = i;
        }
    }
    cout << a[((p + 1 + n) % n)] << "\n";

    return 0;
}