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