#include <bits/stdc++.h>
using namespace std;
int A[100008], B[100008];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B, B + n);
  int i = 0, c = 0;
  while (i != n) {
    if (A[i] != B[i]) c++;
    i++;
  }
  if (c == 0 || c == 2)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
