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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
    cout.tie(NULL);

    int n,k;
    cin >> n >> k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    if(n<=2)
    {
        if(arr[n-1]!=k)
            cout << arr[n-1] << endl;
        else
            cout << arr[n-2] << endl;
    }
    else
    {
        rotate(arr, arr + k, arr + n);
        cout << arr[k+1] << endl;
    }
    return 0;
}