#include <bits/stdc++.h>
using namespace std;
long long n, k, xx, maxx, lastt = -1, recans;
deque<long long> q;
signed main() {
  scanf("%I64d%I64d", &n, &k);
  for (long long i = 1; i <= n; i++) {
    scanf("%d", &xx);
    q.push_back(xx);
    maxx = max(maxx, xx);
  }
  if (k > n) {
    printf("%I64d\n", maxx);
    return 0;
  }
  while (1) {
    long long t1 = q.front();
    q.pop_front();
    long long t2 = q.front();
    q.pop_front();
    if (t1 < t2) swap(t1, t2);
    q.push_back(t2);
    q.push_front(t1);
    if (t1 == lastt)
      recans++;
    else
      recans = 1, lastt = t1;
    if (recans >= k) {
      printf("%I64d\n", t1);
      break;
    }
  }
}
