#include <bits/stdc++.h>
using namespace std;
long long n, m, i, k, j, p, q, y;
long long x[100001];
long long r() {
  long long p = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    p = p * 10 + c - '0';
    c = getchar();
  }
  return p * f;
}
int main() {
  n = r();
  k = r();
  for (i = 1; i <= n; i++) x[i] = r();
  if (n == 2) {
    cout << 2;
    return 0;
  }
  y = max(x[1], x[2]);
  int p = 1;
  for (i = 3; i <= n; i++) {
    if (x[i] > y)
      y = x[i], p = 1;
    else
      p++;
    if (p == k) {
      cout << y;
      return 0;
    }
  }
  cout << y << endl;
  return 0;
}
