module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun a -> a in
  List.sort compare as_
  |> List.fold_left (fun (m, c) a ->
      (IntMap.add a c m, c + 1)) (IntMap.empty, 0)
  |> (fun (m, _) -> List.mapi (fun i a ->
      if i mod 2 = IntMap.find a m mod 2 then 0
      else 1) as_)
  |> List.fold_left ( + ) 0
  |> (fun s -> s / 2)
  |> Printf.printf "%d\n"
