#include <bits/stdc++.h>
using namespace std;
void yesno(bool a) {
  if (a) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  int arr[n];
  int maxi = 0;
  int i;
  deque<int> q;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    q.push_back(arr[i]);
    maxi = max(maxi, arr[i]);
  }
  if (k > n) {
    cout << maxi;
    return 0;
  }
  int cnt[n + 1];
  memset(cnt, 0, sizeof(cnt));
  while (1) {
    int p1 = q.front();
    q.pop_front();
    int p2 = q.front();
    q.pop_front();
    if (p1 > p2) {
      q.push_front(p1);
      q.push_back(p2);
      cnt[p1]++;
    } else {
      q.push_front(p2);
      q.push_back(p1);
      cnt[p2]++;
    }
    if (cnt[p1] == k) {
      cout << p1 << '\n';
      return 0;
    } else if (cnt[p2] == k) {
      cout << p2 << '\n';
      return 0;
    }
  }
}
