#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
  long long n, k;
  cin >> n >> k;
  long long t = k;
  long long x, player = -1;
  for (long long c = 0; c < n; c++) {
    cin >> x;
    if (player == -1)
      player = x;
    else {
      if (player > x)
        t--;
      else
        player = x, t = k - 1;
      if (t == 0) {
        cout << player << endl;
        return 0;
      }
    }
  }
  cout << player << endl;
  return 0;
}
