def bin_digit(n: int):
    return len(bin(n)[2:]) + 1


def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x


MOD = 10**9 + 7

N = int(input())
An = list(map(int, input().split()))

digit = bin_digit(max(An))

res = 0
for d in range(digit):
    n0, n1 = 0, 0
    for i in range(N):
        if An[i] & pow_k(2, d):
            n1 += 1
        else:
            n0 += 1

    temp = pow_k(2, d) % MOD
    n = n0 * n1 % MOD
    temp *= n % MOD
    res = (res + temp) % MOD

print(res)