#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int count = 0;
  queue<int> q;
  int i = 0, x, y;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    q.push(x);
  }
  x = q.front();
  q.pop();
  while (count < k && count != n) {
    y = q.front();
    q.pop();
    if (x > y) {
      count++;
      q.push(y);
    } else {
      count = 1;
      q.push(x);
      x = y;
    }
  }
  cout << x;
  return 0;
}
