#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  if (k >= n) {
    cout << (*max_element(arr + 1, arr + n + 1)) << endl;
  } else {
    for (long long i = 1; i <= n; i++) {
      if (i == 1) {
        bool wrong = 0;
        long long index = i + 1, counter = k;
        if (index > n) {
          index = 1;
        }
        while (counter--) {
          if (arr[i] < arr[index]) {
            wrong = 1;
          }
          index++;
          if (index == n + 1) index = 1;
        }
        if (wrong == 0) {
          cout << arr[i] << endl;
          return 0;
        }
      } else {
        long long maxi = INT_MIN;
        for (long long j = 1; j < i; j++) {
          maxi = max(maxi, arr[j]);
        }
        if (arr[i] > maxi) {
          bool wrong = 0;
          long long index = i + 1, counter = k - 1;
          if (index > n) {
            index = 1;
          }
          while (counter--) {
            if (arr[i] < arr[index]) {
              wrong = 1;
            }
            index++;
            if (index == n + 1) index = 1;
          }
          if (wrong == 0) {
            cout << arr[i] << endl;
            return 0;
          }
        }
      }
    }
  }
}
