#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int N = 1e6 + 10;
const int M = 1e3 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const double f = 0.32349;
int a[N];
void solve() {
  ios::sync_with_stdio(false), cin.tie(0);
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = a[0], id = 0;
  for (int i = 1; i < n; i++) {
    if (id >= k) {
      cout << ans << '\n';
      return;
    }
    if (ans <= a[i]) {
      id = 1;
      ans = a[i];
    } else {
      id++;
    }
  }
  cout << ans << '\n';
}
signed main() {
  solve();
  return 0;
}
