#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k, x;
  cin >> n >> k;
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  bool f = true;
  long long int max = v[0], count = 0;
  for (int i = 1; (i < n) & f; i++) {
    if (v[i] < max) {
      count++;
      if (count == k) f = false;
    } else {
      max = v[i];
      count = 1;
    }
  }
  cout << max;
  return 0;
}
