#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0), EPS = 1e-9;
const int MX = 1 * 1e5 + 10;
int N, M, k;
int arr[MX];
int win[MX];
int main() {
  long long k;
  cin >> N >> k;
  for (int i = 1; i <= N; i++) cin >> arr[i];
  int mx = *max_element(arr + 1, arr + 1 + N);
  int cur_max = arr[1], ans = 1;
  for (int i = 1; i <= N; i++) {
    if (arr[i] == mx) {
      ans = mx;
      break;
    }
    cur_max = max(cur_max, arr[i]);
    if (i > 1 && ++win[cur_max] == k) {
      ans = cur_max;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}
