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

    let rec loop l r cur acc =
        if l = n then acc else
            if r = n || cur land a.(r) <> 0
                then loop (l + 1) r (cur lxor a.(l)) (acc + r - l)
                else loop l (r + 1) (cur lxor a.(r)) acc
    in
    loop 0 1 a.(0) 0 |> Printf.printf "%d\n"
)