N = int(eval(input()))

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



result = 0

for bit in range(60):

    m = 1 << bit

    c = sum(a & m for a in A) >> bit

    result += (c * (N - c)) << bit

    result %= 1000000007

print(result)

import numpy as np



N = int(eval(input()))

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



result = 0

for bit in range(60):

  c = int((A & 1).sum())

  A >>= 1

  result = (result + c * (N - c) * (1 << bit)) % 1000000007

print(result)

N = int(eval(input()))
A = list(map(int, input().split()))
result = 0
for bit in range(60):
    m = 1 << bit
    c = sum(a & m for a in A) >> bit
    result += (c * (N - c)) << bit
    result %= 1000000007
print(result)

import numpy as np

N = int(eval(input()))
A = np.fromiter(list(map(int, input().split())), np.int64)
result = 0
for bit in range(60):
    c = int((A & 1).sum())
    A >>= 1
    result = (result + c * (N - c) * (1 << bit)) % 1000000007
print(result)

+import numpy as np + -A = list(map(int, input().split())) +A = np.fromiter(list(map(int, input().split())), np.int64) -    m = 1 << bit -    c = sum(a & m for a in A) >> bit -    result += (c * (N - c)) << bit -    result %= 1000000007 +    c = int((A & 1).sum()) +    A >>= 1 +    result = (result + c * (N - c) * (1 << bit)) % 1000000007