#include <bits/stdc++.h>
using namespace std;
int n;
int p[51];
int main(){
	cin>>n;
 	for(int i=1; i<=n; i++) cin>>p[i];
 	 int diff=0;
  	for(int j=1; j<=n; j++) diff+=(p[j]!=j);
  if(diff<=2) cout<<"YES\n";
  else cout<<"NO\n";
}