from math import log2,floor
N = int(input())
A = list(map(int,input().split()))
L = max([floor(log2(x)) for x in A])+1
bits = [0]*L
for x in A:
    for i in range(L):
        if (x>>i)&1:
            bits[i] += 1
mod = 10**9+7
ans = 0
for i in range(L):
    b = bits[i]
    ans = (ans+b*(N-b)*(2**i))%mod
print(ans)