#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[500001];
int fir[500001];
int sec[500001];
int minPos[500001];
int minK[500001];
void compute() {
  stack<pair<int, int> > nowlow;
  set<pair<int, int> > nowlow2;
  for (int i = 0; i < N; i++) {
    if (!nowlow2.empty()) {
      auto upb = nowlow2.upper_bound(make_pair(A[i], i));
      for (auto it = upb; it != nowlow2.end(); it++) {
        sec[(*it).second] = i;
      }
      nowlow2.erase(upb, nowlow2.end());
    }
    while (!nowlow.empty() && A[i] < nowlow.top().second) {
      fir[nowlow.top().first] = i;
      nowlow2.insert(make_pair(nowlow.top().second, nowlow.top().first));
      nowlow.pop();
    }
    nowlow.push(make_pair(i, A[i]));
  }
  while (!nowlow.empty()) {
    fir[nowlow.top().first] = N;
    sec[nowlow.top().first] = N;
    nowlow.pop();
  }
  if (!nowlow2.empty()) {
    for (auto it = nowlow2.begin(); it != nowlow2.end(); it++) {
      sec[(*it).second] = N;
    }
  }
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  compute();
  for (int i = 0; i < N; i++) {
    minPos[i] = -1;
  }
  bool needFix = false;
  for (int i = 0; i < N; i++) {
    if (fir[i] - i > K) {
      needFix = true;
    }
    if (sec[i] - i > K) {
      if (minPos[fir[i]] == -1) {
        minPos[fir[i]] = i + 1;
      } else {
        minPos[fir[i]] = max(minPos[fir[i]], i + 1);
      }
    }
  }
  set<int> min_cur;
  for (int i = 0; i < K; i++) {
    min_cur.insert(A[i]);
  }
  for (int i = 0; i < N; i++) {
    if (i >= N - K) {
      minK[i] = numeric_limits<int>::min();
    } else {
      minK[i] = *(min_cur.begin());
      min_cur.erase(min_cur.begin());
      min_cur.insert(A[i + K]);
    }
  }
  if (!needFix) {
    cout << "YES";
    return 0;
  }
  bool foundFix = false;
  for (int i = 0; i < N; i++) {
    if (fir[i] - i > K) {
      for (int j = i + 1; j < N; j++) {
        if (A[j] < A[i] && minPos[j] - i <= K) {
          for (int k = i + K; k > i && k - i <= K && minPos[j] - k <= K; k--) {
            if (minK[j] < A[k]) {
              foundFix = true;
              swap(A[j], A[k]);
              break;
            }
          }
          if (foundFix) {
            break;
          }
        }
      }
      break;
    }
  }
  compute();
  for (int i = 0; i < N; i++) {
    if (fir[i] - i > K) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
