function Main(input) {
	input = input.split("\n");
	var vals = input[1].split(" ");
	var org = input[1].split(" ");
  
  	var count = 0;
  	vals.sort();
  	for(var i=0; i<vals.length; i++)
    {
      if( vals[i] !== org[i] ) count++;
    }
  
  	var ans = (count===0 || count===2) ? "YES" : "NO";
  	//出力
	console.log(ans);
}

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