object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val list = List.fill(sc.nextInt())(sc.nextInt())
  println(if (list.zip(list.sorted).count { case (l, r) => l != r } <= 2) "YES" else "NO")
}
