#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  int cnt[505] = {0};
  long long tem, mx = 0;
  queue<pair<long long, int> > q;
  for (int i = 1; i <= n; i++) {
    cin >> tem;
    q.push({tem, i});
    mx = max(mx, tem);
  }
  pair<long long, int> x = q.front();
  q.pop();
  while (1) {
    pair<long long, int> y = q.front();
    q.pop();
    if (x.first == mx) {
      cout << x.first << endl;
      break;
    }
    if (x.first > y.first) {
      cnt[x.second]++;
      q.push(y);
    } else {
      cnt[y.second]++;
      q.push(x);
      x = y;
    }
    if (cnt[x.second] == k) {
      cout << x.first << endl;
      break;
    }
  }
  return 0;
}
