#include<iostream>
using namespace std;
const int Maxlen = 501;
struct queue{
int q[Maxlen];
int head,tail;
void push(int x){
q[tail]=x;
tail = (tail+1)%Maxlen;
}
void pop(){
head = (head+1)%Maxlen;
}
bool empty(){
return headtail;
}
bool full(){
return (tail+1)%Maxlenhead;
}
int length(){
return (tail+Maxlen-head)%Maxlen;
}
int front(){
return q[head];
}
void init(){
head = tail = 0;
}
};
int main(){
queue a;
a.init();
int n,k;
cin >> n >> k;
for (int i = 0; i < n;i++){
int linshi;
cin >> linshi;
a.push(linshi);
}
bool flag = 1,win = 0;
int tmp = a.front();
a.pop();
while(k != win){
if (a.front() < tmp){
win++;
a.push(a.front());
a.pop();
}else{
win = 0;
a.push(tmp);
tmp = a.front();
a.pop();
}
}
cout << tmp;
return 0;
}