#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (n < k) k = n + 3;
  vector<long> A(n);
  for (long i = 0; i < n; i++) {
    cin >> A[i];
  }
  long score = 0;
  long champ = 0;
  long chal = 1;
  while (score < k) {
    if (champ == chal) {
      chal++;
      chal = chal % n;
    }
    if (A[champ] > A[chal]) {
      chal++;
      chal = chal % n;
      score++;
    } else if (A[champ] < A[chal]) {
      champ = chal;
      score = 1;
      chal = champ + 1;
      chal = chal % n;
    }
  }
  cout << A[champ];
  return 0;
}
