n = int(input())
inf = 10**9+7
a = list(int(x) for x in input().split())
b = []
for key in a:
    p = 0
    while key:
        q = key%2
        if q:
            if p >= len(b):
                b.append(1)
            else:
                b[p] = b[p]+1
        else:
            if p >= len(b):
                b.append(0)
        key = key//2
        p += 1
ans = 0
k = 1
q = 0
for key in b:
    if b[q]:
        ans = (ans+k*(n-b[q])*b[q])%inf
    q += 1
    k *= 2
print(ans)