fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val pointList = readLine()!!.split(" ").map { it.toInt() }
    val ans = pointList.indices.filter{ it + 1 != pointList[it] }.count().let { it == 0 || it == 2 }
    println(if(ans) "YES" else "NO")

}


