import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val ps = readLine.split(" ").map(_.toInt)
  
  def isSorted(a: Array[Int]): Boolean = a.sliding(2).forall(t => t(0) < t(1))
  
  val results = (for {
    i <- 0 until n - 1
    j <- i until n
  } yield {
    val l = ps(i)
    val r = ps(j)
    ps(i) = r
    ps(j) = l
    val result = isSorted(ps)
    ps(i) = l
    ps(j) = r
    result
  }) :+ isSorted(ps)
  
  println(if (results.exists(_ == true)) "YES" else "NO")
}