#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<int> a(n);
  int i;
  int mx_pos = -1;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == n) {
      mx_pos = i;
    }
  }
  int p1 = -1, p2 = -1;
  long long w = 0;
  for (i = 0; w < k && i < mx_pos; i++) {
    if (p1 == -1) {
      p1 = a[i];
    } else if (p2 == -1) {
      p2 = a[i];
    }
    if (p2 != -1) {
      if (p1 < p2) {
        p1 = p2;
        p2 = -1;
        w = 1;
      } else {
        p2 = -1;
        w++;
      }
    }
  }
  if (w == k) {
    cout << p1;
  } else {
    cout << n;
  }
  return 0;
}
