let id x = x
let (+^) x y = (x + y) mod (int_of_float 1e9 + 7)

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

let rec loop sum i t arr =
  if i = 61 then
    print_int sum
  else
    let one = Array.fold_left (fun s n -> s + (n mod 2)) 0 arr in
    loop 
      (sum +^ (one * (n - one)) * t)
      (i + 1)
      (t * 2)
      (Array.map (fun n -> n / 2) arr)

let () = loop 0 0 1 a