from collections import defaultdict

N = int(eval(input()))

A = list(map(int, input().split()))

INF = 10 ** 9 + 7



D = defaultdict(int)

for a in A:

    for i in range(61):

        # a の i ビット目がたっているか否か

        D[1 << i] += bool(a & (1 << i))



ans = 0

for key, value in list(D.items()):

    ans += key * value * (N - value)

    ans %= INF



print((ans % INF))
def cin():

    in_ = list(map(int,input().split()))

    if len(in_) == 1:  return in_[0]

    else:  return in_



N = cin()

A = cin()

INF = 10 ** 9 + 7



res = [0 for _ in range(65)]

for i in range(65):

    c0, c1 = 0, 0

    for j in range(N):

        if bool(A[j] & (1 << i)):  c1 += 1

        else:  c0 += 1

    res[i] = c0 * c1

ans = 0

for i in range(65):  ans = (ans + (1 << i) * res[i]) % INF

print(ans)
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
INF = 10**9 + 7
D = defaultdict(int)
for a in A:
    for i in range(61):
        # a の i ビット目がたっているか否か
        D[1 << i] += bool(a & (1 << i))
ans = 0
for key, value in list(D.items()):
    ans += key * value * (N - value)
    ans %= INF
print((ans % INF))

def cin():
    in_ = list(map(int, input().split()))
    if len(in_) == 1:
        return in_[0]
    else:
        return in_


N = cin()
A = cin()
INF = 10**9 + 7
res = [0 for _ in range(65)]
for i in range(65):
    c0, c1 = 0, 0
    for j in range(N):
        if bool(A[j] & (1 << i)):
            c1 += 1
        else:
            c0 += 1
    res[i] = c0 * c1
ans = 0
for i in range(65):
    ans = (ans + (1 << i) * res[i]) % INF
print(ans)

-from collections import defaultdict +def cin(): +    in_ = list(map(int, input().split())) +    if len(in_) == 1: +        return in_[0] +    else: +        return in_ -N = int(eval(input())) -A = list(map(int, input().split())) + +N = cin() +A = cin() -D = defaultdict(int) -for a in A: -    for i in range(61): -        # a の i ビット目がたっているか否か -        D[1 << i] += bool(a & (1 << i)) +res = [0 for _ in range(65)] +for i in range(65): +    c0, c1 = 0, 0 +    for j in range(N): +        if bool(A[j] & (1 << i)): +            c1 += 1 +        else: +            c0 += 1 +    res[i] = c0 * c1 -for key, value in list(D.items()): -    ans += key * value * (N - value) -    ans %= INF -print((ans % INF)) +for i in range(65): +    ans = (ans + (1 << i) * res[i]) % INF +print(ans)