import math

p = 10 ** 9 + 7

def comb(n):
  if n < 2:
    return(0)
  else:
    a = n % p
    b = (n-1) % p
    c = int((a * b / 2)) % p
    return(c)

n = input()
n = int(n)
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>>j & 1 for k in a] # 各ビットを取り出す
  b = [int(k != 0) for k in b]
  n_one = sum(b)
  n_zero = n - n_one
  r_tmp = comb(n) - (comb(n_zero) + comb(n_one))
  b_tmp = (2 ** j) % p
  r = r + ((r_tmp * b_tmp) % p)
  
print(r % p)