MOD = 1e9 + 7

n = int(input())
tot = 0

cnt = [0] * 64
a = list (map(int, input().split()))
          
for i in range (n) :
    foo = a[i]
    tot += foo
    tot %= MOD
    for mask in range (60):
        cnt[mask] += (a[i] >> mask) & 1

res = 0

for i in range (n):
    cur = a[i]
    tot -= cur
    res += tot
    res %= MOD
    for mask in range (60):
        cnt[mask] -= (a[i] >> mask) & 1
    for mask in range (60):
        if ((cur >> mask) & 1) :
            cnt_not_set = n - i - 1 - cnt[mask]
            cnt_set = cnt[mask]
            res += (1 << mask) * cnt_not_set
            res -= (1 << mask) * cnt_set
            
       
print(res)
