#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    mx = max(a[i].first, mx);
    a[i].second = i;
  }
  vector<pair<int, int>> b = a;
  vector<int> cnt(n);
  int ans = -1;
  for (int i = 0; i < n - 1; ++i) {
    if (a[0] < a[1]) {
      cnt[a[1].second]++;
      a.push_back(a[0]);
      a.erase(a.begin());
    } else {
      cnt[a[0].second]++;
      a.push_back(a[1]);
      a.erase(a.begin() + 1);
    }
    for (int j = 0; j < n; ++j) {
      if (cnt[j] == k) {
        ans = b[j].first;
        cout << ans << "\n";
        return;
      }
    }
  };
  cout << (ans == -1 ? mx : ans) << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
