object Main {

  def main(args: Array[String]): Unit = {
    val _ = io.StdIn.readLine.toInt
    val pList = io.StdIn.readLine.split(" ").map(_.toInt).toList

    def solve(list: List[Int]): String = {

      val number = list.zipWithIndex.count(
        z => z._1 != z._2 + 1
      )



      if (number <= 2) "YES"
      else "NO"
    }

    println(solve(pList))
  }

}
