object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val p = List.fill(n)(sc.nextInt)
    sc.close()

    if (p.zipWithIndex.count(z => z._1 != z._2 + 1) <= 2) println("YES")
    else println("NO")
  }
}