fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val list =  readLine()!!.split(" ").map{it.toInt()}
    var counter=0
    for(i in 1..n){
        if(list[i-1]!=i)counter++
    }
    if(counter==0 || counter==2){
        println("YES")
    }else{
        println("NO")
    }
}