#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r;
  long long k;
  cin >> n;
  cin >> k;
  int i, a[10000], m = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > m) m = a[i];
  }
  if (a[0] == m || k >= n)
    r = m;
  else {
    int c, j, p = 0;
    for (i = 0; i < n - 1; i++) {
      c = 0;
      int x = 0;
      for (j = i + 1; j < n; j++) {
        if (a[i] < a[j]) break;
        if (a[j] < a[i]) {
          c++;
          if (i > 0 && x == 0) {
            c += 1;
            x = 1;
          }
        }
      }
      if (c >= k) {
        r = a[i];
        p = 1;
        break;
      }
    }
    if (p == 0) r = m;
  }
  cout << r << endl;
  return 0;
}
