#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
const int oo = 1000000000;
const int modulo = 1000000007;
int n, m, k;
int a[maxn], pos[maxn];
vector<int> p;
void input() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
bool cmp(int i, int j) { return (a[i] < a[j] || (a[i] == a[j] && i < j)); }
void init() {
  for (int i = 1; i <= n; i++) pos[i] = i;
  sort(pos + 1, pos + n + 1, cmp);
  int j = 1;
  for (int i = 2; i <= n; i++)
    if (a[pos[i]] != a[pos[i - 1]]) {
      j++;
      pos[j] = pos[i];
    }
  m = j;
}
void solve() {
  int cnt = 0, vt;
  p.push_back(0);
  pos[0] = n + 1;
  for (int i = 1; i <= m; i++)
    if (pos[i] < pos[p.back()]) {
      if (pos[p.back()] - pos[i] > k) {
        cnt++;
        vt = p.size() - 1;
        if (cnt > 1 || pos[p.back()] - pos[i] > 2 * k) {
          cout << "NO";
          return;
        }
      }
      p.push_back(i);
    }
  p.push_back(m + 1);
  pos[m + 1] = 0;
  if (cnt == 0) {
    cout << "YES";
    return;
  }
  if (p[vt] + 1 != p[vt + 1]) {
    cout << "YES";
    return;
  }
  if (vt > 0 && pos[p[vt - 1]] - pos[p[vt + 1]] <= 2 * k) {
    bool check = true, check2 = false;
    for (int i = pos[p[vt]] - 1; i > pos[p[vt + 1]] + k; i--)
      if (a[pos[vt]] == a[i]) check = false;
    for (int i = pos[p[vt + 1]] + k; i >= pos[p[vt - 1]] - k; i--)
      if (a[pos[vt]] != a[i]) check2 = true;
    if (check && check2) {
      cout << "YES";
      return;
    }
  }
  cout << "NO";
}
void output() {}
int main() {
  std::ios::sync_with_stdio(false);
  input();
  init();
  solve();
  output();
  return (0);
}
