N=int(eval(input()))

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

ans=0

mod=10**9+7

for i in range(61):

    a=sum([1 for j in A if j>>i & 1])

    ans=ans+a*(N-a)*(2**i)

    ans=ans%mod

print(ans)
import numpy as np

N=int(eval(input()))

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

ans=0

mod=10**9+7

for i in range(61):

    n=np.count_nonzero(A>>i & 1)

    ans+=n*(N-n)<<i

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

import numpy as np

N = int(eval(input()))
A = np.array(list(map(int, input().split())))
ans = 0
mod = 10**9 + 7
for i in range(61):
    n = np.count_nonzero(A >> i & 1)
    ans += n * (N - n) << i
print((ans % mod))

+import numpy as np + -A = list(map(int, input().split())) +A = np.array(list(map(int, input().split()))) -    a = sum([1 for j in A if j >> i & 1]) -    ans = ans + a * (N - a) * (2**i) -    ans = ans % mod -print(ans) +    n = np.count_nonzero(A >> i & 1) +    ans += n * (N - n) << i +print((ans % mod))