import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ps <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let l = length . filter not $ zipWith (==) [1..n] ps
  putStrLn $ if l <= 2 then "YES" else "NO"

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
