#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> cnt(n + 1);
  deque<int> dq(a.begin(), a.end());
  for (int i = 0; i < n - 1; ++i) {
    if (dq[0] > dq[1]) {
      swap(dq[0], dq[1]);
    }
    cnt[dq[1]]++;
    if (cnt[dq[1]] >= k) {
      cout << dq[1] << "\n";
      return;
    }
    dq.push_back(dq[0]);
    dq.pop_front();
  }
  cout << *max_element(a.begin(), a.end()) << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
