import Control.Applicative
import Data.List

main = do
  n <- read <$> getLine :: IO Int
  xs <- (map read).words <$> getLine :: IO [Int]
  let m = length $ filter not $ zipWith (==) xs [1..n]
  if m == 0 || m == 2 then putStrLn "YES" else putStrLn "NO"
