open Printf open Scanf
let input_int_array n =
	Array.init n (fun _ -> Scanf.scanf " %d" (fun v -> v))	
let get_int () = Scanf.scanf " %d" (fun v -> v)
let get_2_ints () = Scanf.scanf " %d %d" (fun u v -> u,v)
let get_3_ints () = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w)
let get_4_ints () = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x)
let get_5_ints () = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)

let print_int_endline n = n |> string_of_int |> print_endline


let () =
	let n = get_int ()
	in let a = input_int_array n
	in
	let newv p n =
		let c = ref (n+p)
		in let f = ref true
		in
		while !f do
			if !c=n || !c=p || !c<1 || !c>10000 then
				c := 1 + Random.int 10000
			else f := false
		done; !c
	in
	let prev,c = ref a.(0),ref 0
	in
	for i=1 to n-1 do
		if a.(i) = !prev then (
			c := !c + 1;
			a.(i) <-
				if i=n-1 then newv !prev 0
				else newv !prev a.(i+1)
		);
		prev := a.(i)
	done;
	!c |> print_int_endline