#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
const long long inf = 1e18;
int toint(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
long long tolint(string s) {
  long long sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
long long a, b, c, d, e, f, g, h, l, m, n, p, k, q, r, t, u, v, w, x, y, z,
    ara[100005] = {0}, arr[100005] = {0};
string s;
int main() {
  cin.tie(0);
  cout.sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= (n); i++) cin >> ara[i];
  if (k >= n - 1) {
    cout << n;
    return 0;
  }
  if (n == 2 || n == 3) {
    cout << n;
    return 0;
  }
  deque<long long> dq;
  for (int i = 1; i <= (n); i++) dq.push_back(ara[i]);
  x = dq.front();
  dq.pop_front();
  p = 0;
  while (1) {
    if (dq.front() > x) {
      p = 1;
      dq.push_back(x);
      x = dq.front();
      dq.pop_front();
    } else {
      a = dq.front();
      dq.pop_front();
      dq.push_back(a);
      p++;
    }
    if (p == k) {
      cout << x;
      return 0;
    }
  }
}
