import Data.List
import Data.Char
main = do
  n <- readLn :: IO Int
  p <- map (read::String->Int) . words <$> getLine
  putStrLn $ if (length . filter (==False) $ zipWith (==) [1..n] p)<=2
    then "YES"
    else "NO"