#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, count = 0;
  cin >> n;
  vector<long long int> arr(n);
  vector<long long int> brr(n);
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    brr[i] = arr[i];
  }
  stable_sort(arr.begin(), arr.end());
  for (long long int i = 0; i < n; i++) {
    if (arr[i] != brr[i]) {
      count++;
    }
  }
  if (count > 2) {
    cout << "NO" << endl;
    return 0;
  } else {
    cout << "YES" << endl;
    return 0;
  }
}
