solve :: [Int] -> Int -> Int
solve [_] cnt = cnt
solve (x1:x2:xs) cnt = solve (x2:xs) cnt'
  where cnt' = if x1 > x2
               then cnt
               else cnt + 1

main :: IO ()
main = do
  getLine
  input <- map read . words <$> getLine
  putStrLn $ if solve input 0 <= 2 then "YES" else "NO"