n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
m2 = [1 for i in range(60)]
for i in range(1,60):
    m2[i] = (m2[i-1]*2)%mod

al = [[(a[j]//(2**i))%2 for i in range(60)] for j in range(n)]
sa = [[0 for i in range(60)] for j in range(n)]
for i in range(n):
    for j in range(60):
        sa[i][j] = sa[i-1][j]+al[i][j]

ans = 0
for i in range(n-1):
    for j in range(60):
        if al[i][j] == 0:
            ans = (ans+(sa[n-1][j]-sa[i][j])*m2[j])%mod
        else:
            ans = (ans+(n-1-i-sa[n-1][j]+sa[i][j])*m2[j])%mod

print(ans)
