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