fun main(args: Array<String>) {
  val N = Integer.parseInt(readLine())
  val line = readLine()
  if (line != null) {
    val list = line.split(" ")
    var sum = 0
    for (i in 1..N) {
      if (Integer.parseInt(list[i-1]) != i) {
        sum += 1
      }
    }
    if (sum <= 2) {
      println("YES")
    } else {
      println("NO")
    }
  }
}