N = int(input())
mod = 10**9 + 7
A = [int(i) for i in input().split()]
bits = [0]*61

ans = 0
for i, a in enumerate(A):
    for b in range(len(bin(a))-2):
        if (a >> b) & 1:
            ans += (2**b)*(i-bits[b])
            bits[b] += 1
        else:
            ans += (2**b)*bits[b]
    ans %= mod
print(ans)
