#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (k >= n - 1) {
    sort(arr, arr + n);
    cout << arr[n - 1];
  } else {
    list<long long int> q;
    long long int pos = 1;
    long long int cnt = 0;
    q.push_back(arr[0]);
    while (3) {
      if (pos == n) {
        sort(arr, arr + n);
        cout << arr[n - 1];
        break;
      }
      if (arr[pos] < q.front()) {
        cnt++;
        if (cnt == k) {
          cout << q.front();
          break;
        }
      } else {
        q.push_front(arr[pos]);
        cnt = 1;
      }
      pos++;
    }
  }
}
