#include <bits/stdc++.h>
using namespace std;
int n, v[500010], bit[500010];
pair<int, int> tree[4 * 500010];
vector<pair<int, int> > val;
void upd(int nod, int a, int b, int i, int x) {
  if (a == b) {
    tree[nod] = pair<int, int>(x, i);
    return;
  }
  if (i <= ((a + b) / 2))
    upd((2 * nod), a, ((a + b) / 2), i, x);
  else
    upd((2 * nod + 1), ((a + b) / 2) + 1, b, i, x);
  tree[nod] = max(tree[(2 * nod)], tree[(2 * nod + 1)]);
}
pair<int, int> query(int nod, int a, int b, int i, int j) {
  if (j < a || i > b || j < i) return pair<int, int>(-1, -1);
  if (i <= a && j >= b) return tree[nod];
  return max(query((2 * nod), a, ((a + b) / 2), i, j),
             query((2 * nod + 1), ((a + b) / 2) + 1, b, i, j));
}
void updBIT(int x, int v) {
  for (int i = x; i < 500010; i += (i & -i)) bit[i] += v;
}
int queryBIT(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= (i & -i)) sum += bit[i];
  return sum;
}
int buscaBIT(int x) {
  int resp = 0;
  for (int i = 21; i >= 0; i--) {
    if (resp + (1 << i) >= 500010) continue;
    if (bit[resp + (1 << i)] <= x)
      x -= bit[resp + (1 << i)], resp = resp + (1 << i);
  }
  if (x == 0)
    return resp + 1;
  else
    return -1;
}
int swap_a, swap_b, k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    val.push_back(pair<int, int>(v[i], i));
  }
  updBIT(n + 1, 1);
  sort(val.begin(), val.end());
  bool no_swap = true;
  for (int i = 0; i < val.size(); i++) {
    int A = queryBIT(val[i].second);
    int p_best = buscaBIT(A);
    updBIT(val[i].second, 1);
    upd(1, 1, n, val[i].second, val[i].first);
    if (p_best - val[i].second <= k) continue;
    pair<int, int> melhor = query(1, 1, n, val[i].second + k, n);
    swap_a = val[i].second + k;
    swap_b = melhor.second;
    no_swap = false;
    break;
  }
  if (no_swap) {
    cout << "YES\n";
    return 0;
  }
  if (swap_b != 0 && swap_a != 0) swap(v[swap_a], v[swap_b]);
  val.clear();
  memset(bit, 0, sizeof bit);
  memset(tree, 0, sizeof tree);
  for (int i = 1; i <= n; i++) {
    val.push_back(pair<int, int>(v[i], i));
  }
  updBIT(n + 1, 1);
  sort(val.begin(), val.end());
  for (int i = 0; i < val.size(); i++) {
    int A = queryBIT(val[i].second);
    int p_best = buscaBIT(A);
    updBIT(val[i].second, 1);
    if (p_best - val[i].second <= k) continue;
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
}
