#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n, diff = 0;
  cin >> n;
  vector<int> arr, arr2;
  arr.resize(n);
  arr2.resize(n);
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    arr[i] = t;
    arr2[i] = t;
  }
  sort(arr2.begin(), arr2.end());
  for (int i = 0; i < n; i++) {
    if (arr[i] != arr2[i]) diff++;
  }
  if (diff <= 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
