#include <bits/stdc++.h>
int n[100010] = {0};
int q[100010] = {0};
int tempArr[3] = {0};
int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int i;
  int m;
  int j, k;
  int tmp = 0;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &n[i]);
    q[i] = n[i];
  }
  qsort(n, m, sizeof(int), comp);
  for (i = 0; i < m; i++) {
    if (n[i] != q[i]) {
      if (tmp >= 2) {
        printf("NO\n");
        return 0;
      }
      tempArr[tmp] = i;
      tmp++;
    }
  }
  if (tmp == 0) {
    printf("YES\n");
  } else {
    j = tempArr[0];
    k = tempArr[1];
    if (q[j] == n[k] || n[j] == q[k]) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
