#include <bits/stdc++.h>
using namespace std;
int MAXINT = numeric_limits<int>::max();
int N;
int main() {
  scanf("%d", &N);
  vector<int> V(N), E(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &V[i]);
    E[i] = V[i];
  }
  sort(E.begin(), E.end());
  int fu = 0;
  for (int i = 0; i < N; i++)
    if (E[i] != V[i]) fu++;
  if (fu > 2)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
