#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  long long int k;
  cin >> n >> k;
  queue<int> q;
  int maxx = INT_MIN;
  for (int i = 0; i < n; i++) {
    int ele;
    cin >> ele;
    maxx = max(maxx, ele);
    q.push(ele);
  }
  if (k >= n - 1)
    cout << maxx;
  else {
    int wins = 0, winner = q.front();
    q.pop();
    while (wins < k) {
      int p2 = q.front();
      q.pop();
      if (winner < p2) {
        winner = p2;
        wins = 1;
        q.push(winner);
      } else {
        wins++;
        q.push(p2);
      }
    }
    cout << winner;
  }
  return 0;
}
