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