#include <bits/stdc++.h>
using namespace std;
int cmpfunc(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int i, j, k, n;
  cin >> n;
  int a[n], b[n];
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  int count = 0;
  for (i = 0; i < n; i++) b[i] = a[i];
  qsort(b, n, sizeof(int), cmpfunc);
  for (i = 0; i < n; i++) {
    if (a[i] != b[i]) count++;
  }
  if (count <= 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
