#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int maxk = 22;
const int INF = 1 << 30;
int a[maxn], b[maxn], d[maxn][maxk], mm[maxn], d1[maxn], d2[maxn], f[maxn];
pair<int, int> p[maxn], q[maxn];
int rmq(int l, int r) {
  int k = mm[r - l + 1];
  return min(d[l][k], d[r - (1 << k) + 1][k]);
}
int gao(int l, int r, int x) {
  while (l < r) {
    int m = (l + r) >> 1;
    if (rmq(l, m) < x)
      r = m;
    else
      l = m + 1;
  }
  return l;
}
tuple<int, int, int> get_p(int n, int k) {
  int l = -1, r = -1, m = INF;
  for (int i = n; i > 0; --i) {
    if (d1[i] - i <= k) {
      if (d2[i] - i > k) {
        if (b[d1[i]] == INF) f[d1[i]] = i;
        b[d1[i]] = min(b[d1[i]], a[i]);
      }
    } else {
      if (l == -1) {
        l = i + 1, r = i + k, m = a[i];
      } else {
        if (i + k < l) return make_tuple(-1, -1, -1);
        r = i + k, m = min(m, a[i]);
      }
    }
  }
  return make_tuple(l, r, m);
}
bool solve(int n, int k, int l, int r, int m) {
  int cnt = 0, cntq = 0;
  for (int i = l; i <= r; ++i) p[++cnt] = pair<int, int>(a[i], i);
  sort(p + 1, p + cnt + 1);
  for (int i = r + 1; i <= n; ++i) q[++cntq] = pair<int, int>(b[i], a[i]);
  sort(q + 1, q + cntq + 1);
  int now = 0;
  for (int i = cnt, j = cntq; i > 0; --i) {
    while (j > 0 && q[j].first > p[i].first) {
      if (q[j].second < m) now = max(now, q[j].second);
      --j;
    }
    if (now > rmq(p[i].second + 1, min(p[i].second + k, n + 1))) return true;
  }
  for (int i = r + 1; i <= n; ++i)
    if (a[i] < m && f[i] && f[i] <= r &&
        rmq(max(f[i], l) + 1, min(r + k, n + 1)) < a[i])
      return true;
  return false;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  mm[0] = -1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    b[i] = INF;
    mm[i] = i & (i - 1) ? mm[i - 1] : mm[i - 1] + 1;
    d[i][0] = a[i];
  }
  for (int j = 1; 1 << j <= n + 1; ++j) {
    for (int i = 1; i + (1 << j) - 1 <= n + 1; ++i)
      d[i][j] = min(d[i][j - 1], d[i + (1 << (j - 1))][j - 1]);
  }
  for (int i = 1; i <= n; ++i) {
    d1[i] = gao(i + 1, n + 1, a[i]);
    if (d1[i] <= n)
      d2[i] = gao(d1[i] + 1, n + 1, a[i]);
    else
      d2[i] = n + 1;
  }
  int l, r, m;
  tie(l, r, m) = get_p(n, k);
  if (m == -1)
    puts("NO");
  else if (m == INF)
    puts("YES");
  else if (solve(n, k, l, r, m))
    puts("YES");
  else
    puts("NO");
  return 0;
}
