#include <bits/stdc++.h>
using namespace std;
const int MN = 500010;
struct BIT {
  vector<int> tree;
  void init() { tree = vector<int>(4 * MN, 1e9); }
  void upd(int idx, int val, int l, int r, int n) {
    if (idx < l || r < idx) return;
    if (l == r) {
      tree[n] = val;
      return;
    }
    int m = (l + r) >> 1;
    upd(idx, val, l, m, 2 * n);
    upd(idx, val, m + 1, r, 2 * n + 1);
    tree[n] = min(tree[2 * n], tree[2 * n + 1]);
  }
  int quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return 1e9;
    if (a <= l && r <= b) return tree[n];
    int m = (l + r) >> 1;
    int L = quer(a, b, l, m, 2 * n);
    int R = quer(a, b, m + 1, r, 2 * n + 1);
    return min(L, R);
  }
} bit;
int N, K;
int A[MN];
vector<pair<int, int> > ord;
int l, r, x;
void check() {
  ord.clear();
  for (int i = 0; i < N; i++) {
    ord.push_back({A[i], i});
  }
  sort(ord.begin(), ord.end());
  bit.init();
  bit.upd(N, N, 0, MN - 1, 1);
  l = 1e9;
  r = -1;
  x = 1e9;
  for (int i = 0; i < N; i++) {
    int idx = ord[i].second;
    int t = bit.quer(idx + 1, MN - 1, 0, MN - 1, 1);
    if (t - idx > K) {
      l = min(l, idx);
      r = max(r, idx);
      x = min(x, A[idx]);
    }
    bit.upd(idx, idx, 0, MN - 1, 1);
  }
}
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  check();
  if (r == -1) {
    printf("YES");
    return 0;
  }
  if (min(N - 1, l + K) < r) {
    printf("NO");
    return 0;
  }
  vector<int> tmp;
  for (int i = r + 1; i < N; i++) {
    if (A[i] < x) {
      tmp.push_back(i);
    }
  }
  tmp.push_back(N);
  if (tmp.size() == 1) {
    printf("NO");
    return 0;
  }
  int mx = -1, a;
  for (int i = 0; i < tmp.size(); i++) {
    if (mx <= A[tmp[i]]) {
      mx = A[tmp[i]];
      a = i;
    }
  }
  int b = -1;
  for (int i = 0; i < tmp.size(); i++)
    if (i != a) {
      if (A[tmp[i]] < A[tmp[a]]) {
        b = tmp[i];
        break;
      }
    }
  if (min(N - 1, l + K) < b - K) {
    printf("NO");
    return 0;
  }
  int mn = 1e9, p;
  for (int i = max(r, b - K); i <= min(N - 1, l + K); i++) {
    if (mn >= A[i]) {
      mn = A[i];
      p = i;
    }
  }
  swap(A[p], A[tmp[a]]);
  check();
  if (r == -1)
    printf("YES");
  else
    printf("NO");
}
