#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  long long n, k, maxx = -1, flag = 0;
  scanf("%lld %lld", &n, &k);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] > maxx) {
      maxx = a[i];
    }
  }
  long long s = 1;
  for (long long i = 1; i <= n; i++) {
    s++;
    if (i != 1 && a[i] > a[i - 1]) {
      flag = 1;
    } else {
      flag = 0;
    }
    for (long long j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) {
        flag++;
      } else {
        break;
      }
    }
    if (flag >= k) {
      printf("%lld\n", a[i]);
      break;
    }
  }
  if (s > n) {
    printf("%lld\n", maxx);
  }
  return 0;
}
