#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, arr[500], ck = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long j = arr[0];
  for (int i = 1; i < n; i++) {
    if (j < arr[i]) {
      ck = 1;
      swap(j, arr[i]);
    } else {
      ck++;
    }
    if (ck == k) break;
  }
  cout << j << endl;
}
