fun main (args:Array<String>){
    val numLen = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").map(String::toInt).toMutableList()

    if(numList == numList.sorted()){
        print("YES")
        return
    }
    for(i in 0..numLen-2){
        for(j in 1..numLen-1){
            numList.swap(i, j)
            if(numList == numList.sorted()){
                print("YES")
                return
            }
            else numList.swap(i, j)
        }
    }
    print("NO")
}

private fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1]
    this[index1] = this[index2]
    this[index2] = tmp
}
