#include <bits/stdc++.h>
using namespace std;
int a[1005];
int kol[1005];
int main() {
  int n;
  cin >> n;
  long long k;
  cin >> k;
  int i0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[n + i] = a[i];
  }
  for (int i = 1; i <= 2 * n; i++) {
    for (int j = i + 1; j <= 2 * n; j++)
      if (a[i] > a[j])
        kol[i]++;
      else
        break;
    if ((kol[i] >= k and i == 1) or (kol[i] >= k - 1 and i > 1)) {
      cout << a[i];
      return 0;
    }
    if (kol[i] == n - 1) {
      i0 = i;
    }
  }
  if (i0 > n) i0 -= n;
  cout << a[i0];
  return 0;
}
