fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val pList = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
  if (pList.isSorted()) {
    println("YES")
    return
  }
  for (i in 0 until n) {
    for (j in i + 1 until n) {
      val l = pList[i]
      val r = pList[j]
      pList[i] = r
      pList[j] = l
      if (pList.isSorted()) {
        println("YES")
        return
      }
      pList[i] = l
      pList[j] = r
    }
  }
  println("NO")
}

fun List<Int>.isSorted(): Boolean {
  this.forEachIndexed { i, v ->
    if (v != i + 1) return false
  }
  return true
}
