import sys

import time



# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。

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)



start = time.time()



MOD = 10**9+7



debug = False



if debug:

    n = 30 * 10000

    A = list(range(n))

else:

    n,*A = get_all_int()



# ビットごとの出現回数 2**i

bits = [0] * 60



for a in A:

    for i in range(60):

        if 2**i & a != 0:

            bits[i] += 1



# log("bits:", bits)

# log("bits.", time.time() - start)



# ans = 0



ans = sum(( pow(2, i, MOD) * bits[i] * (n-bits[i]) for i in range(60))) % MOD



# 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)

print(ans)

# log("end.", time.time() - start)

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。

def get_all_int():

    return list(map(int, open(0).read().split()))



MOD = 10**9+7



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



# その位のビットの1の個数*0の個数 が、そのビットがansに足される回数

ans = sum(( pow(2, i, MOD) * bits[i] * (n-bits[i]) for i in range(60))) % MOD



print(ans)

import sys
import time

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
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)


start = time.time()
MOD = 10**9 + 7
debug = False
if debug:
    n = 30 * 10000
    A = list(range(n))
else:
    n, *A = get_all_int()
# ビットごとの出現回数 2**i
bits = [0] * 60
for a in A:
    for i in range(60):
        if 2**i & a != 0:
            bits[i] += 1
# log("bits:", bits)
# log("bits.", time.time() - start)
# ans = 0
ans = sum((pow(2, i, MOD) * bits[i] * (n - bits[i]) for i in range(60))) % MOD
# 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)
print(ans)
# log("end.", time.time() - start)

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return list(map(int, open(0).read().split()))


MOD = 10**9 + 7
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
# その位のビットの1の個数*0の個数 が、そのビットがansに足される回数
ans = sum((pow(2, i, MOD) * bits[i] * (n - bits[i]) for i in range(60))) % MOD
print(ans)

-import sys -import time - -    return map(int, open(0).read().split()) +    return list(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) - - -start = time.time() -debug = False -if debug: -    n = 30 * 10000 -    A = list(range(n)) -else: -    n, *A = get_all_int() +n, *A = get_all_int() +pow2 = [1] * 61 +for i in range(1, 61): +    pow2[i] = pow2[i - 1] * 2 -        if 2**i & a != 0: +        if pow2[i] & a != 0: -# log("bits:", bits) -# log("bits.", time.time() - start) -# ans = 0 +# その位のビットの1の個数*0の個数 が、そのビットがansに足される回数 -# 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) -# log("end.", time.time() - start)