let n = int (stdin.ReadLine())
let a = stdin.ReadLine().Split() |> Array.map int
let c = Array.map2 (fun x y -> if x <> y then 1 else 0) a (Array.sort a) |> Array.sum
(if c < 3 then "YES" else "NO") |> printfn "%s"