#include <bits/stdc++.h>
using namespace std;
char c1[100005];
vector<int> v;
string s = "";
long long res = 0;
int main() {
  unsigned long long n, k, mx, i(0), d;
  cin >> n >> k;
  n--;
  cin >> d;
  mx = d;
  while (n--) {
    cin >> d;
    if (mx > d) {
      i++;
      if (i == k) {
        cout << mx;
        return 0;
      }
    } else {
      i = 1;
      mx = d;
    }
  }
  cout << mx;
}
