#include <bits/stdc++.h>
using namespace std;
long long cnt[505];
int main() {
  long long n, k, x, ans;
  long long A[505];
  while (cin >> n >> k) {
    for (int i = 0; i < n; i++) cnt[i] = 0;
    for (int i = 0; i < n; i++) cin >> A[i];
    x = 0;
    if (k >= n) {
      sort(A, A + n);
      cout << A[n - 1] << endl;
    } else {
      while (1) {
        int x = A[0];
        int y = A[1];
        if (x > y) {
          cnt[x]++;
          if (cnt[x] == k) {
            ans = x;
            break;
          }
          for (int i = 1; i < n - 1; i++) A[i] = A[i + 1];
          A[n - 1] = y;
        } else {
          cnt[y]++;
          if (cnt[y] == k) {
            ans = y;
            break;
          }
          for (int i = 0; i < n - 1; i++) A[i] = A[i + 1];
          A[n - 1] = x;
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}
