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