object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  var b = Array.fill(n)(sc.nextInt())
  var ar = Range(1,n+1)
  for(i <- 0 until n){
    b(i) = (b(i)-ar(i)).abs
  }
  b = b.sorted
  println(if(b(n-3) == 0) "YES" else "NO")
}
