#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, i, e, f, g, n, m, k, l, A[100005], maxx;
map<int, int> mp;
int main() {
  cin >> n >> k >> A[1];
  maxx = A[1];
  for (i = 2; i <= n; i++) {
    cin >> A[i];
    maxx = max(maxx, A[i]);
    mp[maxx]++;
    if (mp[maxx] == k) {
      cout << maxx;
      return 0;
    }
  }
  cout << maxx;
}
