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