#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;
using std::queue;
using std::string;
int main() {
  int n;
  cin >> n;
  long long k;
  cin >> k;
  int data[501] = {
      0,
  };
  for (int i = 1; i <= n; i++) {
    cin >> data[i];
  }
  if (k > n - 1) {
    cout << n;
    return 0;
  }
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    q.push(data[i]);
  }
  int win = 0;
  int left = q.front();
  q.pop();
  while (true) {
    int right = q.front();
    q.pop();
    if (left > right) {
      win++;
      q.push(right);
    } else {
      q.push(left);
      left = right;
      win = 1;
    }
    if (win == k) {
      cout << left;
      return 0;
    }
  }
  return 0;
}
