#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    q.push(x);
  }
  int tmp = q.front(), c = 0;
  q.pop();
  while (true) {
    if (tmp == n) {
      cout << n;
      return 0;
    }
    if (tmp > q.front()) {
      q.push(q.front());
      q.pop();
      c++;
    } else {
      tmp = q.front();
      q.push(tmp);
      q.pop();
      c = 1;
    }
    if (c == k) {
      cout << tmp;
      return 0;
    }
  }
  return 0;
}
