N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

li = [0 for i in range(61)]

for i in range(0, len(A)):
    _a = A[i]
    for j in range(len(li))[::-1]:
        quo = _a // pow(2, j)
        li[j] += quo
        _a -= quo*pow(2, j)


res = 0
for i in range(len(li)):
    res += (pow(2, i) * (li[i]*(N-li[i])))%MOD
    res %= MOD
print(res)
