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