#include <bits/stdc++.h>
using namespace std;
vector<long long> vec;
int main() {
  long long n, i, j, k, p, q, x, y;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> p;
    vec.push_back(p);
  }
  i = j = 0;
  while (j < min(n, k)) {
    if (vec[i] > vec[i + 1]) {
      swap(vec[i], vec[i + 1]);
      vec.push_back(vec[i]);
      j++;
    } else {
      vec.push_back(vec[i]);
      j = 1;
    }
    i++;
  }
  printf("%I64d\n", vec[i]);
  return 0;
}
