function Main(input) {
	input = input.split("\n");
	var N = input[0];
	var arr = input[1].split(" ");
	var sabun = arr.slice(0, arr.length);
	var count = 0;
	arr = arr.sort(function(a,b){return a-b;});
	for(var i=0;i<arr.length;i++){
		if(arr[i]!=sabun[i]) count++;
	}
	if(count==0||count==2){
		console.log("YES")
	}else{
		console.log("NO")
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());