#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], temp[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    temp[i] = arr[i];
  }
  sort(temp, temp + n);
  int cnt = 0;
  int ii;
  int a;
  for (int i = 0; i < n; i++) {
    if (arr[i] != temp[i]) {
      cnt++;
      a = arr[i];
      ii = i;
    }
  }
  if (cnt == 0) return cout << "YES", 0;
  bool b = 0;
  for (int i = 0; i < n; i++) {
    if (temp[i] == a) {
      if (arr[i] == temp[ii]) {
        b = 1;
        break;
      }
    }
  }
  if ((b && cnt == 2) || cnt == 0)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
