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