fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var p = readLine()!!.split(" ").map { it.toInt()}
    var pCopy = p.map { it }.sortedBy { it }
    var bo = 0
    for (i in 0 until n){
        if (p[i] != pCopy[i]) bo++
    }
    if (bo == 2 || bo == 0) println("YES")
    else println("NO")
}