#include <bits/stdc++.h>
using namespace std;
long long int fexpo(long long int a, long long int b) {
  if (b == 0) return 1LL;
  if (b == 1) return a;
  if (b == 2) return ((a) * (a));
  if (b % 2 == 0)
    return fexpo(fexpo(a, b / 2), 2);
  else
    return ((a) * (fexpo(fexpo(a, (b - 1) / 2), 2)));
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  deque<pair<long long int, long long int> > q;
  long long int n, k;
  cin >> n >> k;
  int mxe = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > mxe) mxe = x;
    q.push_back(make_pair(x, 0));
  }
  long long int check = 0;
  while (true) {
    check++;
    long long int u1, v1, u2, v2;
    u1 = q.front().first;
    v1 = q.front().second;
    q.pop_front();
    u2 = q.front().first;
    v2 = q.front().second;
    q.pop_front();
    if (v1 >= k) {
      return cout << u1 << endl, 0;
    }
    if (v2 >= k) return cout << u2 << endl, 0;
    if (check > 6 * 1e7) {
      return cout << mxe << endl, 0;
    }
    if (u1 > u2) {
      q.push_back(make_pair(u2, 0));
      q.push_front(make_pair(u1, v1 + 1));
    } else {
      q.push_back(make_pair(u1, 0));
      q.push_front(make_pair(u2, v2 + 1));
    }
  }
}
