#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  deque<int> Q;
  for (int i = 0; i < n; i++) {
    int power;
    cin >> power;
    Q.push_back(power);
  }
  int absoluteWinner = 0;
  int lastWinner = 0;
  int winsInARow;
  for (int i = 0; i < n - 2; i++) {
    int A = Q.front();
    Q.pop_front();
    int B = Q.front();
    Q.pop_front();
    int winner = max(A, B);
    int loser = min(A, B);
    if (winner == lastWinner) {
      winsInARow++;
    } else {
      winsInARow = 1;
    }
    lastWinner = winner;
    Q.push_back(loser);
    Q.push_front(winner);
    if (winsInARow == k) {
      absoluteWinner = winner;
      break;
    }
  }
  if (absoluteWinner > 0) {
    cout << absoluteWinner << endl;
  } else {
    cout << n << endl;
  }
}
