import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val p = (1..n).map { sc.nextInt() }
    val sorted = p.sorted()
    var count = 0
    for (i in p.indices) {
        if (p[i] != sorted[i]) {
            count++
        }
    }
    println(if (count == 0 || count == 2) "YES" else "NO")
}