import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine()
  val p = StdIn.readLine().split(" ").map(_.toInt).toList
  println(if ((for ((i,j) <- (p zip p.sorted) if (i != j)) yield (i,j)).length <= 2) "YES" else "NO")
}
