#include <bits/stdc++.h>
using namespace std;
void mejor(int player, long long int k, int *arr, int n) {
  if (player == 0) {
    if (player + k >= n - 1)
      cout << n << endl;
    else {
      for (int i = 0; i < k; i++) {
        if (arr[player] < arr[player + 1 + i]) {
          mejor(player + 1 + i, k, arr, n);
          return;
        }
      }
      cout << arr[player] << endl;
    }
  } else {
    if (player + k > n - 1)
      cout << n << endl;
    else {
      for (int i = 0; i < k - 1; i++) {
        if (arr[player] < arr[player + 1 + i]) {
          mejor(player + 1 + i, k, arr, n);
          return;
        }
      }
      cout << arr[player] << endl;
    }
  }
  return;
}
int main() {
  int n;
  long long int k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (k >= n - 1)
    cout << n << endl;
  else
    mejor(0, k, arr, n);
  return 0;
}
