{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  n <- readLn
  ps <- readIntsLn
  putStrLn $ if solve n ps then "YES" else "NO"

solve :: Int -> V.Vector Int -> Bool
solve _ ps = l <= 2
  where l = V.length $ V.ifilter (\i x -> (i + 1) /= x) ps

readIntsLn :: IO (V.Vector Int)
readIntsLn = V.unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine
