let n = Scanf.scanf " %d" (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let css = Array.make_matrix 2 100001 0
let ms = ref [|0, 0; 0, 0|]
let e0, e1, o0, o1 = Array.iteri (fun i v -> let c = css.(i mod 2).(v) + 1 in css.(i mod 2).(v) <- c; !ms.(i mod 2) <- max !ms.(i mod 2) (c, v)) vs;
  List.iter (fun i -> Array.sort (fun x y -> compare y x) css.(i)) [0; 1];
  css.(0).(0), css.(0).(1), css.(1).(0), css.(1).(1)
let _ = Printf.printf "%d\n" @@ if snd !ms.(0) = snd !ms.(1) then n - max (e0 + o1) (e1 + o0) else n - e0 - o0