#include <bits/stdc++.h>
using namespace std;
const int maxn = 600;
long long n, k;
int num;
queue<int> que;
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%I64d%I64d", &n, &k) != EOF) {
    int Max = 0;
    while (!que.empty()) {
      que.pop();
    }
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &num);
      que.push(num);
      Max = max(Max, num);
    }
    if (k > n) {
      printf("%d\n", Max);
    } else {
      int win = 0;
      num = que.front();
      que.pop();
      while (true) {
        if (num > que.front()) {
          int tmp = que.front();
          que.pop();
          que.push(tmp);
          ++win;
        } else {
          que.push(num);
          num = que.front();
          que.pop();
          win = 1;
        }
        if (win >= k) {
          break;
        }
      }
      printf("%d\n", num);
    }
  }
  return 0;
}
