#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX, MOD = 1e9 + 7;
const int L = 17, N = 1 << L;
long long n, k;
queue<pair<long long, long long> > a;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push({i + 1, x});
  }
  k = min(n, k);
  pair<long long, long long> champ = a.front();
  a.pop();
  long long win = 0;
  for (int i = 0; i < n * 4; i++) {
    pair<long long, long long> chal = a.front();
    a.pop();
    if (champ.second > chal.second) {
      a.push(chal);
      win++;
      if (win >= k) break;
    } else {
      a.push(champ);
      champ = chal;
      win = 1;
    }
  }
  cout << champ.second << endl;
  return 0;
}
