#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int n, k, cnt = 0, mxx = 0, curr = 0;
  scanf("%lld%lld", &n, &k);
  long long int err[n];
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &err[i]);
  }
  curr = err[0];
  for (int i = 1; i < n; ++i) {
    if (err[i] > curr) {
      curr = err[i];
      cnt = 1;
    } else {
      ++cnt;
      if (cnt >= k) {
        break;
      }
    }
  }
  printf("%lld\n", curr);
  return 0;
}
