#include <bits/stdc++.h>
using namespace std;
void priyanshu() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  priyanshu();
  long long n, k;
  cin >> n >> k;
  long long a[n], maxm = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    maxm = max(maxm, a[i]);
  }
  long long j = 0, flag = 0;
  if (a[0] < a[1]) flag = 1;
  if (n <= 2)
    cout << max(a[0], a[1]);
  else {
    for (long long i = 1; i < n; i++) {
      if (a[j] > a[i])
        flag++;
      else {
        j = i;
        flag = 1;
      }
      if (flag == k) {
        cout << a[j] << endl;
        break;
      }
    }
    if (flag != k) cout << maxm << endl;
  }
}
