fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map(String::toInt)
    val sorted = list.sorted()
    var diff = 0
    for (i in 0 until list.size) {
        if (list[i] != sorted[i]) {
            diff++
        }

        if (3 <= diff) {
            println("NO")
            return
        }

    }
    if (diff == 2 || diff == 0) {
        println("YES")
    } else {
        println("NO")
    }
}
