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

let () = Scanf.scanf "%d\n" @@ fun n ->
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun v -> v in
  let (odds, evens) =
    Array.fold_left (fun (odds, evens) v ->
      (evens, IntMap.add v (1 + try IntMap.find v odds with Not_found -> 0) odds))
    (IntMap.empty, IntMap.empty) vs in
  Printf.printf "%d\n" @@ ( - ) n @@
  match
    List.sort (fun (_, x) (_, y) -> compare y x) @@
    IntMap.bindings odds,
    List.sort (fun (_, x) (_, y) -> compare y x) @@
    IntMap.bindings evens
  with
  | [(u, l)], [(v, m)] ->
      if u = v then max l m else l + m
  | (u, l) :: (_, m) :: _, [(v, n)] -> 
      if u = v then max l (m + n) else l + n
  | [(u, l)], (v, m) :: (_, n) :: _ -> 
      if u = v then max (l + n) m else l + m
  | (u, l) :: (_, m) :: _, (v, n) :: (_, o) :: _ ->
      if u = v then max (l + o) (m + n) else l + n
