fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map(String::toInt)
    val miss = (1..N).count { it != p[it - 1] }
    println(if (miss <= 2) "YES" else "NO")
}