n = int(input())
lst = list(map(int,input().split()))
sum = 0
MOD = 10**9+7
max_x = max(lst) 
max_length = len(bin(max_x))-2

for i in range(max_length,-1,-1):
    #ビットにある0,1の数を数えていく.
    cnt_0 = 0
    cnt_1 = 0
    for x in lst:
        if bin( x >> i )[-1] == '1':
            cnt_1 +=1
        else:
            cnt_0 +=1
    sum += cnt_0 * cnt_1 * (1 << i)
    sum = sum % MOD

print(sum)