#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int k=0;
  for(int i=0; i<N; i++){
    int p;
    cin >> p;
    if(p != i+1) k++;
  }
  if(k<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}