#include <bits/stdc++.h>
using namespace std;
int a[505];
long long cnt[505];
int main() {
  int n;
  long long k;
  cin >> n >> k;
  int _max = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    _max = max(_max, a[i]);
  }
  if (a[1] == _max) return 0 * printf("%d", _max);
  int m = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == _max) return 0 * printf("%d", _max);
    if (a[m] > a[i]) cnt[m]++;
    if (cnt[m] >= k) return 0 * printf("%d", a[m]);
    if (a[i] > a[m]) cnt[i]++, m = i;
    if (cnt[m] >= k) return 0 * printf("%d", a[m]);
  }
  return 0;
}
