N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
m = 62
d =[0]*m
ans = 0
for i in range(N):
    for j in range(m):
        if A[i]&(1<<j):
            ans += (1<<j)*(i-d[j])
            d[j] += 1
        else:
            ans += (1<<j)*d[j]
    ans %= mod
print(ans%mod)