#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
inline void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  boostIO();
  long long int n, k;
  cin >> n >> k;
  vector<long long int> A(n * 2);
  for (int i = 0; i < (n); ++i) {
    cin >> A[i];
  }
  long long int Spes = A[0];
  long long int Index = n;
  for (int i = 1; i < n; ++i) {
    if (A[i] < Spes) {
      A[Index] = A[i];
      ++Index;
    } else {
      A[Index] = Spes;
      ++Index;
      Spes = A[i];
    }
  }
  if (A[n * 2 - 1] == 0) A[n * 2 - 1] = Spes;
  int Min = A[0];
  for (int i = 0; i < (n); ++i) {
    long long int Temp = 0;
    if (A[i] > Min) ++Temp;
    long long int j = i + 1;
    while (A[j] < A[i]) {
      ++Temp;
      ++j;
    }
    if (A[j] == A[i]) {
      cout << A[i];
      return 0;
    }
    if (Temp >= k) {
      cout << A[i];
      return 0;
    }
  }
  return 0;
}
