#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  int fg = 0, a[505];
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (k >= n)
    cout << n << endl;
  else {
    for (int i = 0; i < n; i++) {
      int s = 0;
      if (i != 0 && a[i] > a[i - 1]) s = 1;
      for (int j = 1; j <= k - s; j++) {
        int pos = (i + j) % n;
        if (a[i] < a[pos]) break;
        if (j == k - s) {
          fg = 1;
          cout << a[i] << endl;
          break;
        }
      }
      if (fg) break;
    }
  }
  return 0;
}
