n = int(input())
a = [int(i) for i in input().split()]

mod = 10**9+7

#sum_a = sum(a)

#bin_num = format(2, 'b')
#print(bin_num,len(bin_num))

max_a = max(a)
bin_max_a = format(max_a, 'b')

#print(bin_max_a)
ans = 0

for i in range(len(bin_max_a)):
    tmp = 0
    #print(i)
    kazu = 0
    for j in range(n):
        #print(j,kazu)
        kazu += int(format(a[j], 'b').zfill(len(bin_max_a))[i])
        #print(a[j],int(format(a[j], 'b').zfill(len(bin_max_a))[i]))
        #print(format(a[j], 'b').zfill(len(bin_max_a))[i])
        #print(kazu)
    if kazu == 0:
        continue
    tmp = kazu*(n-kazu) % mod
    tmp1 = 1
    """
    for i in range(len(bin_max_a)-1-i):
        tmp1 *= 2
        tmp1 %= mod
    """
    tmp1 = 2**(len(bin_max_a)-1-i) % mod
    tmp = tmp*tmp1%mod
    ans += tmp
    ans %= mod
    #print(ans,kazu)
    
print(ans)