#include <bits/stdc++.h>
using namespace std;
int n, Sum, a[500000], b[500000];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) Sum++;
  if (Sum <= 2)
    printf("YES");
  else
    printf("NO");
  return 0;
}
