#bit表記を足せればいいんだけど...。
import numpy as np#単純に足し合わせるのは繰り上がりに対応できない
n = int(input())
lst = list(map(int,input().split()))
MOD = 10**9+7
max_x = max(lst) 
max_length = len(bin(max_x))-2
lst = [bin(x)[2:] for x in lst]
cnt_1 = [0]*max_length#ここに記録していく.
cnt_0 = [0]*max_length

for x in lst:
    for i in range(1,max_length+1):
        if len(x) < i:
            cnt_0[i-1] += 1
        else:
            if x[-i] == '1':
                cnt_1[i-1] += 1
            else:
                cnt_0[i-1] += 1
ans=0
for i in range(0,max_length):
    cnt_0_i = cnt_0[i]
    cnt_1_i = cnt_1[i]
    ans += cnt_0_i * cnt_1_i * (1 << i)
    ans = ans % MOD
print(ans)