#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    q.push(x);
  }
  int a = q.front();
  q.pop();
  int b = q.front();
  q.pop();
  int curr = max(a, b);
  q.push(min(a, b));
  int c = 1;
  while (c < k && curr < n) {
    int nd = q.front();
    q.pop();
    if (curr > nd) {
      c++;
      q.push(nd);
    } else {
      c = 1;
      q.push(curr);
      curr = nd;
    }
  }
  cout << curr;
}
