import math

N = int(input())
A = [int(i) for i in input().split()]
maxA = max(A)
if maxA == 0:
    print(0)
else:   
    digs = int(math.log(maxA, 2)+1)
    count = [0] * digs
    
    for A_i in A:
        A_bit = format(A_i, 'b')
        for j in range(len(A_bit)):
            count[j] += int(A_bit[len(A_bit)-1-j])
    total = 0
    for i in range(digs):
        total += (2**i * count[i] * (N - count[i])) % 1000000007
        
    print(total % 1000000007)