solve :: Int -> [Int] -> String
solve n p
    | diffCount <= 2 = "YES"
    | otherwise = "NO"
        where diffCount = length $ filter (\(a, b) -> a /= b) $ zip [1..n] p


main :: IO()
main = do
    line <- getLine
    let n = read line :: Int
    line <- getLine
    let p = map read $ words line :: [Int]
    putStrLn $ solve n p