#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5 + 5;
const long long mod = 1e18;
long long power(long long a, long long b) {
  if (b == 0) return 1LL;
  long long d = power(a, b / 2);
  d *= d;
  d %= mod;
  if (b % 2) d *= a;
  d %= mod;
  return d;
}
long long inv(long long a, long long MOD) { return power(a, MOD - 2); }
long long bs(long long a[], long long n, long long key) {
  long long s = 1;
  long long e = n;
  while (s <= e) {
    long long mid = (s + e) / 2;
    if (a[mid] == key)
      return mid;
    else if (a[mid] > key)
      e = mid - 1;
    else
      s = mid + 1;
  }
  return -1;
}
long long a[N];
long long n;
long long k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(8);
  cout << fixed;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  if (k > n - 1) {
    sort(a + 1, a + n + 1);
    cout << a[n] << endl;
    return 0;
  }
  int ans = 0;
  int cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (cnt == k || i == n) {
      ans = a[i];
      break;
    }
    if (a[i] > a[i + 1]) {
      swap(a[i], a[i + 1]);
      cnt++;
    } else
      cnt = 1;
  }
  cout << ans << endl;
  return 0;
}
