
object Main extends App {
  import scala.io.StdIn._
  val n = readInt()
  val nums = readLine().trim.split(' ').map(_.toInt)
  val sorted = nums.sorted
  println(
    if (nums.zip(sorted).count{case (a, b) => a != b} <= 2) "YES" else "NO"
  )
}