import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- map (read::String -> Int) . words <$> getLine
  let mismatch = foldl (\acc i -> if arr !! (i - 1) /= i then acc + 1 else acc) 0 [1..n]
  putStrLn $ if mismatch <= 2 then "YES" else "NO"
