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