function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const ps = input[1].split(" ").map(x => parseInt(x))

	var count = 0
	for(i=0; i < N; i++){
		if(ps[i] != i+1) count++
	}
	if(count == 2 || count == 0){
		console.log("YES")
	}else{
		console.log("NO")
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));