#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int a[100000], b[100000];
int main() {
  int n, i, cnt = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  qsort(a, n, sizeof a[0], cmp);
  for (i = 0; i < n; i++)
    if (a[i] != b[i]) cnt++;
  puts(cnt <= 2 ? "YES" : "NO");
  return 0;
}
