yesno 0 = "YES"
yesno 2 = "YES"
yesno _ = "NO"

count :: [Int] -> Int
count xs = snd $ foldl step (1, 0) xs
    where step (k, a) i = (k+1, a + (if k == i then 0 else 1))

main = do
  n <- readLn :: IO Int
  p <- map read . words <$> getLine :: IO [Int]
  putStrLn $ yesno $ count p
