#include <bits/stdc++.h>
using namespace std;
int arr1[100010];
int arr2[100010];
int main() {
  int i, n, idx1 = -1, idx2 = -1;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", &arr1[i]);
    ;
    arr2[i] = arr1[i];
  }
  sort(arr2, arr2 + n);
  for (i = 0; i < n; i++) {
    if (arr1[i] != arr2[i]) {
      if (idx1 == -1)
        idx1 = i;
      else if (idx2 == -1)
        idx2 = i;
      else {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  if (idx1 != -1 && idx2 != -1) {
    if (arr1[idx1] != arr2[idx2] || arr1[idx2] != arr2[idx1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
