#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
long long power(long long a, long long b, long long m = 1000000007) {
  long long ans = 1;
  a = a % m;
  while (b > 0) {
    if (b & 1) ans = (1ll * a * ans) % m;
    b >>= 1;
    a = (1ll * a * a) % m;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
bool isprime(long long n) {
  if (n < 2) return 0;
  long long i = 2;
  while (i * i <= n) {
    if (n % i == 0) return 0;
    i++;
  }
  return 1;
}
bool isPowerOfTwo(int x) { return x && (!(x & (x - 1))); }
struct cmp {
  bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const {
    return lhs.first * rhs.second < lhs.second * rhs.first;
  }
};
bool cmps(pair<int, int> p1, pair<int, int> p2) {
  return p1.second > p2.second;
}
double distform(int x, int y, int z, int w) {
  return sqrt(1. * pow(x - z, 2) + 1. * pow(y - w, 2));
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const int MAXN = 2e5 + 10;
int32_t main() {
  auto start = std::chrono::high_resolution_clock::now();
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[2 * n];
  long long maxEle = INT_MIN;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    a[n + i] = a[i];
    maxEle = max(maxEle, a[i]);
  }
  long long ans = 0;
  if (k >= n - 1) {
    cout << maxEle << "\n";
  } else {
    for (long long i = 0; i < n; ++i) {
      bool flag = true;
      if (i > 0) {
        for (long long j = i - 1; j <= i + k - 1; ++j) {
          if (i != j)
            if (a[i] <= a[j]) {
              flag = false;
              break;
            }
        }
        if (flag) {
          cout << a[i] << "\n";
          break;
        }
      } else {
        for (long long j = i + 1; j <= i + k; ++j) {
          if (a[i] <= a[j]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          cout << a[i] << "\n";
          break;
        }
      }
    }
  }
  auto stop = std::chrono::high_resolution_clock::now();
  auto duration =
      std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
  cerr << "Time taken : " << fixed
       << ((long double)duration.count()) / ((long double)1e9) << "s "
       << "\n";
}
