#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return ((a * b) / gcd(a, b));
}
void scanint(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, k, i, j, a, b;
  cin >> n >> k;
  int ar[n + 505];
  int mi = 0, mv = -1;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] > ar[mi]) {
      mi = i;
    }
  }
  if (k >= mi) {
    cout << ar[mi] << endl;
  } else {
    int vic[n + 1], f = 0;
    memset(vic, 0, sizeof(vic));
    for (i = 0; i < n - 1; i++) {
      mv = max(ar[i], ar[i + 1]);
      ar[i + 1] = mv;
      vic[mv]++;
      if (vic[mv] == k) {
        f = 1;
        cout << mv << endl;
        break;
      }
    }
    if (f == 0) cout << ar[mi] << endl;
  }
  return 0;
}
