import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  ps <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  putStrLn $ if solve n ps then "YES" else "NO"

solve :: Int -> U.Vector Int -> Bool
solve n = (<= 2) . U.length . U.filter id . U.zipWith (/=) (U.fromList [1..n])