#include <bits/stdc++.h>
using namespace std;
int n, A[100005], B[100005], sayac;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    B[i] = A[i];
  }
  sort(A + 1, A + n + 1);
  for (int i = 1; i <= n; i++) {
    if (A[i] != B[i]) {
      sayac++;
    }
  }
  if (sayac == 0) {
    printf("YES");
    return 0;
  }
  if (sayac == 2) {
    printf("YES");
    return 0;
  }
  printf("NO");
  return 0;
}
