fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: 0
    val input = readLine() ?: ""
    val input_list = input.split(" ")
        .map(String::toInt) 
    val asc_list = (1..n).toList()

    var count = 0
    input_list.zip(asc_list)
        .forEach {
            when (it.first == it.second) {
                true -> {}
                false -> count++
            }
        }
    when (count > 2 ) {
        true -> println( "NO" )
        false -> println( "YES" )
    }
}