#include <bits/stdc++.h>
using namespace std;
int comp(const void *p, const void *q) { return *(int *)p - *(int *)q; }
int a[100010], b[100010];
int main() {
  int i, j, n, f;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  memcpy(b, a, sizeof(a));
  qsort(b, n, sizeof(int), comp);
  f = 0;
  for (i = 0; i < n; i++)
    if (a[i] != b[i]) f++;
  printf("%s\n", (f > 2) ? "NO" : "YES");
  return 0;
}
