#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
int N;
int arr[MAXN];
int sorted[MAXN];
int compare(int A[], int B[]) {
  int errors = 0;
  for (int i = 0; i < N; ++i)
    if (A[i] != B[i]) ++errors;
  return errors;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &arr[i]);
    sorted[i] = arr[i];
  }
  sort(sorted, sorted + N);
  int errors = compare(arr, sorted);
  if (errors <= 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
