import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  ps <- map read.words <$> getLine :: IO [Int]
  if [1..n] == ps || (2 == length (filter (\(i,i') -> i /= i') $ zip [1..n] ps))  then putStrLn $ "YES"
    else putStrLn $ "NO"
