N = int(input())
*A, = map(int, input().split())

d1 = [[0]*60 for _ in range(N+1)]
mod = 10**9+7

for i, n in enumerate(A):
    for j in range(60):
        d1[i+1][j] = d1[i][j]
        if n%(2**(j+1)):
            d1[i+1][j] += 1
        n //= 2

ans = 0
for i, n in enumerate(A, start=1):
    for j in range(60):
        a = d1[N][j]-d1[i][j] # 1
        b = N-a-i # 0

        if n%(2**(j+1)):
            ans += (b*(2**j))%mod
        else:
            ans += (a*(2**j))%mod
        n //= 2

print(ans%mod)