fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map{it.toInt()}
    val k = p.zip((1 .. n)).filter{it.first != it.second}.size
    println(if(k == 2 || k == 0) "YES" else "NO")
}
