#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long int ans = a[0], cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] < ans)
      cnt++;
    else {
      cnt = 1;
      ans = a[i];
    }
    if (cnt == k) break;
  }
  cout << ans << endl;
  return 0;
}
