function Main(input){
var N = new Number(input.split("\n")[0]);
var p = input.split("\n")[1].split(" ");
var origin = [];
for(i=0;i<=(N-1);i++){
  origin[i] = i+1;
}
var judge;
var count=0;
for(j=0;j<=(N-1);j++){
  judge = parseInt(origin[j],10) == parseInt(p[j],10);
  if(judge==false){
    count += 1;
  } 
}
if(count==2||count==0){
  console.log("YES");
}else{
  console.log("NO");
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));