import math
from math import factorial

p = 10 ** 9 + 7
def cmb(n):
  a = n % p
  b = (n - 1) % p
  return(int((a * b / 2)) % p)

n = input()
a = input().split(" ")

a = [int(i) for i in a]

bmax = math.ceil(math.log2(max(a)))

r = 0

for j in range(bmax):
  b = [k & (2 ** j) for k in a] # 各ビットを取り出す
  b = [int(k != 0) for k in b]
  n_tot = len(b)
  n_one = sum(b)
  n_zero = n_tot - n_one
  r_tmp = cmb(n_tot) - (cmb(n_zero) + cmb(n_one))
  b_tmp = (2 ** j) % p
  r = r + ((r_tmp * b_tmp) % p)
  
print(r % p)