#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int MR = 5e5 + 10;
const int inf = 1e9;
int a[MR];
pair<int, int> tab[MR];
int n;
int t[2 * MR];
void build() {
  for (int i = n - 1; i > 0; --i) t[i] = min(t[i << 1], t[i << 1 | 1]);
}
void modify(int p, int value) {
  for (t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = min(t[p], t[p ^ 1]);
}
int query(int l, int r) {
  int res = inf;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min(res, t[l++]);
    if (r & 1) res = min(res, t[--r]);
  }
  return res;
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  n++;
  for (int i = 0; i < (n - 1); ++i) {
    scanf("%d", &tab[i].first);
    tab[i].second = i;
    t[i + n + 1] = inf;
  }
  t[n] = n - 1;
  n--;
  sort(tab, tab + n);
  int ind = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && tab[j].first == tab[i].first) j++;
    ind++;
    for (int l = (i); l < (j); ++l) a[tab[l].second] = ind;
    i = j;
  }
  n++;
  build();
  int A = -1, C = -1;
  for (int i = (n - 1) - 1; i >= (0); --i) {
    int ans = query(0, a[i]);
    if (ans - i > k) {
      A = i;
      if (C == -1) C = i;
    }
    modify(a[i], i);
  }
  if (A == -1) {
    printf("YES\n");
    return 0;
  }
  if (C >= A + k) {
    printf("NO\n");
    return 0;
  }
  int pos = -1;
  for (int i = (A + k + 1); i < (n - 1); ++i)
    if (a[i] < a[A]) {
      if (pos == -1 || a[i] > a[pos]) pos = i;
    }
  if (pos == -1) {
    printf("NO\n");
    return 0;
  }
  swap(a[A + k], a[pos]);
  for (int i = 0; i < (n - 1); ++i) t[i + n + 1] = inf;
  t[n] = n - 1;
  build();
  for (int i = (n - 1) - 1; i >= (0); --i) {
    int ans = query(0, a[i]);
    if (ans - i > k) {
      printf("NO\n");
      return 0;
    }
    modify(a[i], i);
  }
  printf("YES\n");
  return 0;
}
