#include <bits/stdc++.h>
using namespace std;
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int len;
  cin >> len;
  unsigned long arr[len];
  unsigned long arrSorted[len];
  for (int i = 0; i < len; i++) {
    cin >> arr[i];
    arrSorted[i] = arr[i];
  }
  qsort(arrSorted, len, sizeof(unsigned long), compare);
  int err = 0;
  for (int i = 0; i < len; i++) {
    if (arr[i] != arrSorted[i]) err++;
    if (err > 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
