import sys

input = sys.stdin.readline



N = int(eval(input()))

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

MOD = 10**9+7

A = [format(Ai, 'b') for Ai in A]

L = max(len(Ai) for Ai in A)

A = ['0'*(L-len(Ai))+Ai for Ai in A]

ans = 0



for i in range(L):

    one, zero = 0, 0

    

    for j in range(N):

        if A[j][i]=='1':

            one += 1

        else:

            zero += 1

    

    add = pow(2, L-i-1, MOD)*one*zero%MOD

    ans += add

    ans %= MOD



print(ans)
import sys

input = sys.stdin.readline



N = int(eval(input()))

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

ans = 0

MOD = 10**9+7



for i in range(65):

    one = 0

    zero = 0

    

    for j in range(N):

        if (A[j]>>i)&1:

            one += 1

        else:

            zero += 1

    

    ans += one*zero*pow(2, i, MOD)

    ans %= MOD



print(ans)
import sys

input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
A = [format(Ai, "b") for Ai in A]
L = max(len(Ai) for Ai in A)
A = ["0" * (L - len(Ai)) + Ai for Ai in A]
ans = 0
for i in range(L):
    one, zero = 0, 0
    for j in range(N):
        if A[j][i] == "1":
            one += 1
        else:
            zero += 1
    add = pow(2, L - i - 1, MOD) * one * zero % MOD
    ans += add
    ans %= MOD
print(ans)

import sys

input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
MOD = 10**9 + 7
for i in range(65):
    one = 0
    zero = 0
    for j in range(N):
        if (A[j] >> i) & 1:
            one += 1
        else:
            zero += 1
    ans += one * zero * pow(2, i, MOD)
    ans %= MOD
print(ans)

+ans = 0 -A = [format(Ai, "b") for Ai in A] -L = max(len(Ai) for Ai in A) -A = ["0" * (L - len(Ai)) + Ai for Ai in A] -ans = 0 -for i in range(L): -    one, zero = 0, 0 +for i in range(65): +    one = 0 +    zero = 0 -        if A[j][i] == "1": +        if (A[j] >> i) & 1: -    add = pow(2, L - i - 1, MOD) * one * zero % MOD -    ans += add +    ans += one * zero * pow(2, i, MOD)