#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long int MOD = 998244353;
double eps = 1e-12;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  deque<long long int> v(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  if (k >= n) {
    cout << *max_element(v.begin(), v.end()) << endl;
  } else {
    long long int st[n];
    memset(st, 0, sizeof(st));
    while (true) {
      long long int a = v[0];
      long long int b = v[1];
      v.pop_front(), v.pop_front();
      if (a > b) {
        st[a - 1]++;
        v.push_front(a);
        v.push_back(b);
      } else {
        st[b - 1]++;
        v.push_front(b);
        v.push_back(a);
      }
      long long int max = *max_element(st, st + n);
      if (max >= k) {
        for (long long int i = 0; i < n; i++) {
          if (st[i] == max) {
            cout << i + 1 << endl;
            return;
          }
        }
      }
    }
  }
}
