fun main(args: Array<String>) {
//    val mod = 1000000007L
    val mod = 2019
    val N = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map(String::toInt).toList()

    var isSwap = 0

    for ((i,p) in P.withIndex()) {
        if (i+1 != p) isSwap++
    }
    println(if(isSwap <= 2) "YES" else "NO")
}