function Main(input) {
  var list = input.split("\n")[1].split(" ");
  var mismatch = [];
  for(var i = 0; i < list.length; i++){
    var tmp = parseInt(list[i]);
    if(tmp != i + 1){
       mismatch.push(tmp);
    }
  }
  if(mismatch.length == 0 || mismatch.length == 2){
     console.log("YES");
     return;
  }else{
    console.log("NO");
     return;
  }
  /*
  list[mismatch[0]] = mismatch[0];
  list[mismatch[1]] = mismatch[1];
  for(var i = 0; i < list.length; i++){
    var tmp = parseInt(list[i]);
    if(tmp != i){
       mismatch.push(tmp);
    }
  }*/
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
