#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long a[300010], cnt[300010];
long long n, k, maxx;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    maxx = max(maxx, a[i]);
  }
  int pos = 1, cnt = 0;
  while (a[pos] != maxx) {
    for (int i = pos + 1; i <= n; ++i) {
      if (a[pos] > a[i]) {
        cnt++;
        if (cnt >= k) {
          cout << a[pos];
          return 0;
        }
      } else {
        cnt = 1;
        pos = i;
        break;
      }
    }
  }
  cout << maxx;
  return 0;
}
