#include<iostream>
using namespace std;
int n;
int p[51];
int sum=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		if(p[i]!=i)
			sum++;
	}
	if(sum>=3)
		cout<<"NO\n";
	else cout<<"YES\n";
	return 0;
}