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
  let u, x1, x2 =
    match 
      List.sort (fun (_, x) (_, y) -> compare y x) @@
      IntMap.bindings odds
    with
    | [(u, x1)] -> u, x1, 0
    | (u, x1) :: (_, x2) :: _ -> u, x1, x2
  and v, y1, y2 =
    match 
      List.sort (fun (_, x) (_, y) -> compare y x) @@
      IntMap.bindings evens
    with
    | [(v, y1)] -> v, y1, 0
    | (v, y1) :: (_, y2) :: _ -> v, y1, y2 in
  Printf.printf "%d\n" @@ n -
    if u <> v then x1 + y1 else max (x1 + y2) (x2 + y1)
