#include <bits/stdc++.h>
using namespace std;
long long a, b, k, n, w;
int main() {
  cin >> n >> k >> a;
  for (int i = 1; i < n && a != n; ++i) {
    cin >> b;
    if (a < b) {
      a = b;
      w = 0;
    }
    ++w;
    if (w == k) {
      cout << a << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}
