#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
vector <int> vec;
int n, counter = 0;
cin>>n;

for(int i=0; i<n; i++){

   int num;
   cin>>num;
   vec.push_back(num);

}

for(int i=0; i<n; i++){
    if(vec.at(i) != i+1){
     counter++;
}
}

if(counter <= 2){
    cout<<"YES"<<endl;
}else{
    cout<<"NO"<<endl;
}
      



}