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 _ = Array.iteri (fun i v -> css.(i mod 2).(v) <- css.(i mod 2).(v) + 1) vs
let cssi = Array.map (fun cs -> Array.mapi (fun i c -> c, i) cs) css
let (e0, em), e1, (o0, om), o1 = List.iter (fun i -> Array.sort (fun x y -> compare y x) cssi.(i)) [0; 1];
  cssi.(0).(0), fst cssi.(0).(1), cssi.(1).(0), fst cssi.(1).(1)
let _ = Printf.printf "%d\n" @@ if em = om then n - max (e0 + o1) (e1 + o0) else n - e0 - o0