main = do
 str <- getLine
 let a = read str :: Integer
 let sequense = [1..a]
 line <- getLine
 let xs = [read x ::Integer | x <- (words line)]
 let diff = sum [ 1 | (x, y) <- zip sequense xs, x /= y ]
 if diff == 2 || diff == 0 then putStrLn "YES" else putStrLn "NO"
