#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, power[1000], s = 0, i, p, maxpower = 0;
  long long int k;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> power[i];
    if (power[i] > maxpower) maxpower = power[i];
  }
  p = power[0];
  if (p == maxpower)
    cout << p << endl;
  else
    for (i = 1; i < n; i++) {
      if (p > power[i]) s++;
      if (s == k) {
        cout << p << endl;
        break;
      }
      if (p < power[i]) {
        p = power[i];
        if (p == maxpower) {
          cout << p << endl;
          break;
        }
        s = 1;
      }
    }
  return 0;
}
