M = 10**9+7

N = int(eval(input()))

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



ans = 0

for k in range(61):

    N1 = 0

    N1 = sum([1 for a in A if ( (a >> k) & 1)])

    ans += (((1<<k)) *(N-N1) *N1)

    ans %= M    



print(ans)
import numpy as np

M = 10**9+7

N = int(eval(input()))

A = np.array(list(map(int,input().split())),dtype='int64')

ans = 0



maxA = np.amax(A)

K = len(str(bin(maxA)))-2



for k in range(K):

    N1 = 0

    N1 = np.sum((A >> k) & 1)

    N0 = N-N1

    ans += (((1<<k)%M) *N0%M) *N1%M

    ans %= M



print(ans)
M = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ((a >> k) & 1)])
    ans += ((1 << k)) * (N - N1) * N1
    ans %= M
print(ans)

import numpy as np

M = 10**9 + 7
N = int(eval(input()))
A = np.array(list(map(int, input().split())), dtype="int64")
ans = 0
maxA = np.amax(A)
K = len(str(bin(maxA))) - 2
for k in range(K):
    N1 = 0
    N1 = np.sum((A >> k) & 1)
    N0 = N - N1
    ans += (((1 << k) % M) * N0 % M) * N1 % M
    ans %= M
print(ans)

+import numpy as np + -A = list(map(int, input().split())) +A = np.array(list(map(int, input().split())), dtype="int64") -for k in range(61): +maxA = np.amax(A) +K = len(str(bin(maxA))) - 2 +for k in range(K): -    N1 = sum([1 for a in A if ((a >> k) & 1)]) -    ans += ((1 << k)) * (N - N1) * N1 +    N1 = np.sum((A >> k) & 1) +    N0 = N - N1 +    ans += (((1 << k) % M) * N0 % M) * N1 % M