#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, p1, p2, flag, z;
  long long k, c1 = 0, c2 = 0;
  cin >> n >> k;
  if (k > n)
    z = n;
  else
    z = k;
  list<int> powers;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    powers.push_back(p);
  }
  p1 = powers.front();
  powers.pop_front();
  p2 = powers.front();
  powers.pop_front();
  while (true) {
    if (c1 == (z)) {
      cout << p1 << "\n";
      break;
    }
    if (c2 == (z)) {
      cout << p2 << "\n";
      break;
    }
    if (p1 > p2) {
      c1 += 1;
      c2 = 0;
      powers.push_back(p2);
      p2 = powers.front();
      powers.pop_front();
    } else {
      c2 += 1;
      c1 = 0;
      powers.push_back(p1);
      p1 = powers.front();
      powers.pop_front();
    }
  }
}
