import math
from math import factorial

p = 10 ** 9 + 7
def comb(n,k):
  """power_funcを用いて(nCk) mod p を求める"""
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2)*power_func(c,p-2))%p
def power_func(a,b):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1))%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 = comb(n_tot, 2) - (comb(n_zero, 2) + comb(n_one, 2))
  b_tmp = (2 ** j) % p
  r = r + ((r_tmp * b_tmp) % p)
  
print(r % p)