let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let c = ref 0
let _ = Array.iteri (fun i p -> if p <> i + 1 then incr c) ps; print_endline @@ if !c > 2 then "NO" else "YES"