import numpy as np



N = int(eval(input()))

mod = 10**9 + 7

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



ans = 0

for i in range(60):

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

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

    ans %= mod

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

print(ans)



import sys

import numpy as np

MOD = 10**9+7



n = int(sys.stdin.buffer.readline())

a = np.fromstring(sys.stdin.buffer.readline(), dtype = np.int64, sep = ' ')

ans = 0

for i in range(60):

    s = int((a&1).sum())

    ans += s*(n-s) * 2**i

    ans %= MOD

    a >>= 1

print(ans)

import numpy as np

N = int(eval(input()))
mod = 10**9 + 7
A = np.array(input().split(), int)
ans = 0
for i in range(60):
    b = np.count_nonzero(A >> i & 1)
    ans += 2**i * (b * (N - b))
    ans %= mod
    c = np.count_nonzero(A >> i & 1)
print(ans)

import sys
import numpy as np

MOD = 10**9 + 7
n = int(sys.stdin.buffer.readline())
a = np.fromstring(sys.stdin.buffer.readline(), dtype=np.int64, sep=" ")
ans = 0
for i in range(60):
    s = int((a & 1).sum())
    ans += s * (n - s) * 2**i
    ans %= MOD
    a >>= 1
print(ans)

+import sys -N = int(eval(input())) -mod = 10**9 + 7 -A = np.array(input().split(), int) +MOD = 10**9 + 7 +n = int(sys.stdin.buffer.readline()) +a = np.fromstring(sys.stdin.buffer.readline(), dtype=np.int64, sep=" ") -    b = np.count_nonzero(A >> i & 1) -    ans += 2**i * (b * (N - b)) -    ans %= mod -    c = np.count_nonzero(A >> i & 1) +    s = int((a & 1).sum()) +    ans += s * (n - s) * 2**i +    ans %= MOD +    a >>= 1