fun main(args: Array<String>) {
    readLine()
    val list = readLine()!!.split(" ").map { it.toInt() }

    val diffCount = list.filterIndexed{ index, i -> index+1 != i }.count()

    println(if (diffCount > 2) "NO" else "YES")
}
