#include <bits/stdc++.h>
using namespace std;
const int N = 555;
int n, i;
int a[N];
int cnt[N];
int Q[N * N * 10];
long long k;
int main() {
  cin >> n >> k;
  k = min(k, n - 1LL);
  for (i = (1); i <= (n); i++) cin >> a[i], Q[i] = i;
  int L = 2, R = n;
  int c = 1;
  while (1) {
    if (a[c] < a[Q[L]]) {
      Q[++R] = c;
      c = Q[L++];
    } else
      Q[++R] = Q[L++];
    if (++cnt[c] == k) {
      cout << a[c];
      return 0;
    }
  }
}
