#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, aux, i;
  vector<int> vet;
  vector<int> vetOrd;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> aux;
    vet.push_back(aux);
    vetOrd.push_back(aux);
  }
  sort(vetOrd.begin(), vetOrd.end());
  int countDif = 0;
  for (i = 0; i < n; i++) {
    if (vet[i] != vetOrd[i]) {
      countDif++;
    }
  }
  if (countDif > 2) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
