#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int i, n, k;
  cin >> n >> k;
  deque<unsigned long long int> P;
  unsigned long long int temp;
  for (i = 0; i < n; i++) {
    cin >> temp;
    P.push_back(temp);
  }
  if (n == 2) {
    cout << max(P[0], P[1]);
    return 0;
  }
  unsigned long long int count = 0;
  unsigned long long int one, two, win;
  one = P.front();
  P.pop_front();
  two = P.front();
  P.pop_front();
  if (one > two) {
    win = one;
    P.push_back(two);
  } else {
    win = two;
    P.push_back(one);
  }
  count++;
  while (1) {
    if (k - 1 > n - 1) {
      P.push_front(win);
      cout << *(max_element(P.begin(), P.end()));
      return 0;
    } else {
      two = P.front();
      P.pop_front();
      if (win > two) {
        count++;
        P.push_back(two);
        if (count == k) {
          cout << win;
          return 0;
        }
      } else {
        P.push_back(win);
        win = two;
        count = 1;
      }
    }
  }
  return 0;
}
