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

fun readInputLine(): String {
    return readLine()!!
}
