#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  int c = 0;
  while (a[0] != n && c < k)
    if (a[0] > a[1]) {
      int d = a[1];
      a.erase(begin(a) + 1);
      a.push_back(d);
      ++c;
    } else {
      int d = a[0];
      a.erase(begin(a));
      a.push_back(d);
      c = 1;
    }
  cout << a[0];
  return 0;
}
