#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long exp, long long mod = (1000000007LL)) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2) {
      res = (res * base) % mod;
    }
    base = (base * base) % mod;
    exp /= 2;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    gcd(b, a % b);
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int sod(long long n) {
  int sum = 0;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
void printvector(vector<long long> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
int visited[10] = {0};
int branch = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  if (k >= n) k = n + 1;
  deque<long long> q;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    q.push_back(x);
  }
  long long wins = 0;
  while (wins < k) {
    long long val1 = q.front();
    q.pop_front();
    long long val2 = q.front();
    q.pop_front();
    if (val1 > val2) {
      q.push_back(val2);
      q.push_front(val1);
      wins++;
    } else {
      q.push_back(val1);
      q.push_front(val2);
      wins = 1;
    }
  }
  cout << q.front() << endl;
}
