-- problem B - "0 or 1 swap"
main = do
  getLine
  ns <- map read . words <$> getLine
  if solve ns
    then putStrLn "YES"
    else putStrLn "NO"

solve :: [Int] -> Bool
solve  = (<3) . length . filter id . zipWith (/=) [1..]