import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    [n] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    pi <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    let ideal = [(x, x) | x <- [1..n]]
        p = zip [1..n] pi
        result = ideal \\ p

    putStrLn $ if (length result) <= 2
        then "YES"
        else "NO"
