let () = Scanf.scanf "%d\n" @@ fun n ->
  let pp = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun d -> d - 1 in
  let changed = ref 0 in
  for i = 0 to n - 1 do
    if pp.(i) <> i then changed := !changed + 1
  done;
  Printf.printf "%s\n" @@
    if !changed <= 2 then "YES" else "NO"
