#include <bits/stdc++.h>
using namespace std;
long long int ciel(long long int x, long long int y) {
  if (x % y) {
    return x / y + 1;
  }
  return x / y;
}
long long int perm(long long int n) { return ((n - 1) * n) / 2; }
void swap(long long int x, long long int y) {
  long long int t = x;
  x = y;
  y = t;
}
long long int sq(long long int x) { return x * x; }
void what_should_be_the_logic() {
  long long int n, j, i;
  cin >> n;
  long long int a[n];
  long long int k, cnt = 0, mx = 0;
  cin >> k;
  for (i = 0; i <= n - 1; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  if (mx == a[0] || n <= k) {
    cout << mx << "\n";
    return;
  }
  mx = max(a[0], a[1]);
  for (i = 1; i <= n - 1; i++) {
    if (mx < a[i]) {
      cnt = 1;
      mx = a[i];
    } else {
      cnt++;
    }
    if (cnt == k) {
      cout << mx << "\n";
      return;
    }
  }
  cout << mx << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  what_should_be_the_logic();
  return 0;
}
