import sys
input = sys.stdin.readline
MOD = pow(10, 9) + 7

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD



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

m = max(a)

k = len(format(m, 'b'))

num = [0] * k

for x in a:
    for j in range(k):
        if (x >> j) & 1:
            num[j] += 1

fact, factinv = make_fact_list(max(num), MOD)

s = 0

#print(num)

for i in range(k):
    s += (n - num[i]) * num[i] * pow(2, i, MOD) % MOD

print(s % MOD)