Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i acc =
        if i = n then acc else
            if a.(i) = a.(i - 1) then (
                a.(i) <- -i;
                loop (i + 1) (acc + 1)
            ) else loop (i + 1) acc
    in
    loop 1 0 |> Printf.printf "%d\n"
)