import sys
 
# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())
 
def log(*args):
    print("DEBUG:", *args, file=sys.stderr)
 
def int_to_bits(x):
    return [ 1 if 2**i & x != 0 else 0 for i in range(60) ]
 
def inv(x, MOD):
    return pow(x, MOD-2, MOD)
 
MOD = 10**9+7
 
debug = False
 
if debug:
    n = 50000
    A = list(range(n))
else:
    n,*A = get_all_int()
 
 
pow2 = [1] * 61
for i in range(1,61):
    pow2[i] = pow2[i-1] * 2

# ビットごとの出現回数 2**i
bits = [0] * 60

for a in A:
    for i in range(60):
        if pow2[i] & a != 0:
            bits[i] += 1

 
# log("bits:", bits)
 
ans = 0
 
for a in A:
    # a_bits = [ 1 if 2**i & a != 0 else 0 for i in range(60) ]
 
    for i in range(60):
        ans += 2**i * abs(bits[i] - (1 if 2**i & a != 0 else 0) *n)
 
    # a_dash = list(map(lambda a: a*(n-1), a_bits))
 
    # log("a_dash", a_dash)
 
    # bits_dash = [ bits[i] - a_bits[i] for i in range(60)]
    # log("bits_dash", bits_dash)
    # ans += sum( ( 2**i * abs(bits_dash[i]-2*a_dash[i])) for i in range(60) )
 
    # ans += sum( ( 2**i * abs(bits[i]-2*a_dash[i])) for i in range(60) )
 
    # for i in range(60):
    #     ans = (ans + 2**i * abs(bits_dash[i] - a_dash[i])) % MOD
    # log(a, ans)
 
print(ans//2 % MOD)