#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  int d[n];
  int t = 0, ma = -1;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] > ma) {
      ma = d[i];
      t = i;
    }
  }
  long long int p = d[0], l = 0;
  for (int i = 1; i < t; i++) {
    if (d[i] > p) {
      l = 1;
      p = d[i];
    } else {
      l++;
    }
    if (l == k) {
      cout << p << endl;
      return 0;
    }
  }
  cout << ma << endl;
  return 0;
}
