#include <bits/stdc++.h>
using namespace std;
const int maxm = 100005;
int a[maxm], flag[maxm];
int main() {
  long long k;
  int n, i, j, sum;
  scanf("%d%lld", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  int now = a[1];
  for (i = 2; i <= n; i++) {
    if (now > a[i]) {
      flag[now]++;
      if (flag[now] == k) {
        printf("%d\n", now);
        return 0;
      }
    } else {
      now = a[i], flag[a[i]]++;
      if (flag[a[i]] == k) {
        printf("%d\n", a[i]);
        return 0;
      }
    }
  }
  printf("%d\n", n);
  return 0;
}
