#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<int> v;
  int a[n], l = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  int max = a[0], u = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  if (n <= k) {
    cout << max;
  } else {
    for (int i = 0;; i++) {
      if (v[1] < v[0]) {
        v.push_back(v[1]);
        v.erase(v.begin() + 1);
        l++;
        if (l == k) {
          cout << v[0];
          break;
        } else if (l < k) {
          continue;
        }
      } else if (v[1] > v[0]) {
        v.push_back(v[0]);
        v.erase(v.begin());
        l = 1;
      }
    }
  }
  return 0;
}
