main = do
    n <- readLn :: IO Int
    pn <- map read . words <$> getLine :: IO [Int]
    let x = sum $ zipWith (\x y -> if x == y then 0 else 1) [1..n] pn
    if x <= 2 && head pn == 1 && last pn == n
        then putStrLn "YES"
        else putStrLn "NO"
    