import qualified Data.ByteString.Char8 as BS
import Data.Char
import Debug.Trace
import Data.List
import Control.Monad
import Data.Vector.Unboxed as UV


main = do
    n <- UV.head . UV.unfoldr BS.readInt <$> BS.getLine
    p <- UV.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let l = UV.length $ UV.filter not $ UV.zipWith (==) p (UV.fromList [1..n])
    putStrLn $ if l <= 2 then "YES" else "NO"
