function Main(input){
  input = input.split("\n")  
  var array = input[1].split(" ")
  array = array.map(e=>parseInt(e))  
  var array2=array.slice().sort((a,b)=>(a<b?-1:1))  
  var count = 0;
  array.forEach((e,i)=>{
    if(e!=array2[i])count++
  })  
  if(count==2 || count==0){
    console.log("YES")
  }else{
    console.log("NO")
  }
}

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