from itertools import count



n = int(eval(input()))

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



d_cumsum = [0] * 60

for v in a:

    for i in count():

        d_cumsum[i] += v % 2

        v //= 2

        if v == 0:

            break



res = 0

mod = 10**9 + 7

for i, d in enumerate(d_cumsum):

    res += (2**i * d * (n-d)) % mod

    res %= mod



print(res)

import numpy as np



n = int(eval(input()))

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



res = 0

mod = 10**9 + 7

for i in range(61):

    cnt = np.count_nonzero(a >> i & 1)

    res += cnt * (n-cnt) << i

    res %= mod



print(res)

from itertools import count

n = int(eval(input()))
a = list(map(int, input().split()))
d_cumsum = [0] * 60
for v in a:
    for i in count():
        d_cumsum[i] += v % 2
        v //= 2
        if v == 0:
            break
res = 0
mod = 10**9 + 7
for i, d in enumerate(d_cumsum):
    res += (2**i * d * (n - d)) % mod
    res %= mod
print(res)

import numpy as np

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

-from itertools import count +import numpy as np -a = list(map(int, input().split())) -d_cumsum = [0] * 60 -for v in a: -    for i in count(): -        d_cumsum[i] += v % 2 -        v //= 2 -        if v == 0: -            break +a = np.array(list(map(int, input().split()))) -for i, d in enumerate(d_cumsum): -    res += (2**i * d * (n - d)) % mod +for i in range(61): +    cnt = np.count_nonzero(a >> i & 1) +    res += cnt * (n - cnt) << i