let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  print_endline @@ if
    ( >= ) 2 @@
    Array.fold_left ( + ) 0 @@
    Array.init n @@ fun i ->
      if ps.(i) = i + 1 then 0 else 1
  then "YES"
  else "NO"

