#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y = -1, i = 0;
  long long k, cnt = 0;
  cin >> n >> k;
  while (i < n) {
    cin >> x;
    if (y < x) {
      if (i != 0) cnt = 1;
      y = x;
    } else
      cnt++;
    if (cnt == k) break;
    i++;
  }
  cout << y;
  return 0;
}
