#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long d = 0;
  if (k >= n)
    cout << n << endl;
  else {
    for (int i = 0; i < n; i++) {
      for (int j = i + 1;; j++) {
        if (v[i] > v[j]) {
          d++;
          v.push_back(v[j]);
          if (d >= k) {
            cout << v[i] << endl;
            return 0;
          }
        } else {
          d = 1;
          v.push_back(v[i]);
          i = j - 1;
          break;
        }
      }
    }
  }
}
