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