object Main extends App {
  val n = io.StdIn.readLine.toInt
  val p = io.StdIn.readLine.split(" ").map(_.toInt)

  var c = 0
  for(i <- 0 to p.length - 2; if p(i) >= p(i + 1)) c += 1

  if(c < 2){
    println("YES")
  }else{
    println("NO")
  }
}
