n = int(input())
a = list(map(int,input().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

li = [[0,0] for _ in range(61)]

for i in range(n):  
    s = Base_10_to_n(a[i],2).zfill(61)
    for j in range(61):
        if s[j] == "1":
            li[60-j][1] += 1
        else:
            li[60-j][0] += 1

point = 0
mod = 10**9+7

for i in range(61):
    mi = min(li[i])
    if mi == 0:
        continue
    for j in range(i):
        mi *= 2
        mi %= mod
    point += mi
    point %= mod

point *= n-1
point %= mod

print(point)