import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



MOD = 10 ** 9 + 7

N = ir()

A = lr()

bit = [0 for _ in range(60)]

for a in A:

    for i in range(a.bit_length()):

        if (a >> i) & 1:

            bit[i] += 1



answer = 0

for i, x in enumerate(bit):

    answer += x * (N-x) * 2 ** i



print((answer%MOD))

# 22
import sys

import numpy as np



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



MOD = 10 ** 9 + 7

N = ir()

A = np.array(lr(), np.int64)

answer = 0

limit = int(A.max()).bit_length()

for i in range(limit):

    B = (A >> i) & 1

    x = np.count_nonzero(B)

    y = N - x

    add = (x*y) * 2 ** i % MOD

    answer += add



print((answer%MOD))

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = lr()
bit = [0 for _ in range(60)]
for a in A:
    for i in range(a.bit_length()):
        if (a >> i) & 1:
            bit[i] += 1
answer = 0
for i, x in enumerate(bit):
    answer += x * (N - x) * 2**i
print((answer % MOD))
# 22

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
N = ir()
A = np.array(lr(), np.int64)
answer = 0
limit = int(A.max()).bit_length()
for i in range(limit):
    B = (A >> i) & 1
    x = np.count_nonzero(B)
    y = N - x
    add = (x * y) * 2**i % MOD
    answer += add
print((answer % MOD))

+import numpy as np -A = lr() -bit = [0 for _ in range(60)] -for a in A: -    for i in range(a.bit_length()): -        if (a >> i) & 1: -            bit[i] += 1 +A = np.array(lr(), np.int64) -for i, x in enumerate(bit): -    answer += x * (N - x) * 2**i +limit = int(A.max()).bit_length() +for i in range(limit): +    B = (A >> i) & 1 +    x = np.count_nonzero(B) +    y = N - x +    add = (x * y) * 2**i % MOD +    answer += add -# 22