


object Main extends App {

  val n = scala.io.StdIn.readLine.toInt
  val p: Array[Int] = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  def solve(): String = {
    var cnt = 0
    for(i <- 0 until n) {
      if(i+1 != p(i)) cnt += 1
    }
    if(cnt <= 2) "YES" else "NO"
  }
  println(solve)
}
