#include <bits/stdc++.h>
int main() {
  int n;
  long long k, now = 0LL;
  scanf("%d%I64d", &n, &k);
  int *mas = new int[n * 4], a;
  for (int i = 0; i < n; i++) {
    scanf("%d", &mas[i]);
    mas[i + n + n + n] = (mas[i + n + n] = (mas[i + n] = mas[i]));
  }
  a = mas[0];
  for (int i = 1; i < n; i++) {
    if (mas[i] > a) {
      a = mas[i];
      now = 1LL;
    } else
      now++;
    if (now == k) break;
  }
  printf("%d\n", a);
  return 0;
}
