#include <bits/stdc++.h>
using namespace std;
int main() {
  int length, backToBack;
  scanf("%d%d", &length, &backToBack);
  int count = 0;
  long long winnerForce;
  scanf("%lld", &winnerForce);
  for (int i = 1; i < length; i++) {
    long long force;
    scanf("%lld", &force);
    if (count < backToBack) {
      if (force > winnerForce) {
        winnerForce = force;
        count = 1;
      } else
        count++;
    }
  }
  printf("%d", winnerForce);
  return 0;
}
