let kVMax = 100_000
let n = Scanf.scanf " %d" @@ (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let css = Array.init 2 @@ fun _ -> Array.init (kVMax + 1) @@ fun i -> 0, i
let _ =
  if n = 2 then (Printf.printf "%d\n" @@ if vs.(0) = vs.(1) then 1 else 0; exit 0);
  for i = 0 to n - 1 do
    let m, j = css.(i land 1).(vs.(i)) in
    css.(i land 1).(vs.(i)) <- m + 1, j
  done;
  for i = 0 to 1 do Array.sort (fun x y -> compare y x) css.(i) done;
  let (max0, i), (max1, j) = css.(0).(0), css.(1).(0) in
  Printf.printf "%d\n" @@ if i <> j then n - max0 - max1
    else n - max (max0 + fst css.(1).(1)) (fst css.(0).(1) + max1)