#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("CAU1.INP","r",stdin);
    freopen("CAU1.OUT","w",stdout);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for (int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<k;i++)
    {
        int d=a[0];
        a.erase(a.begin());
        a.push_back(d);
    }
    cout<<a[0];

    return 0;
}
