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')
        j=0
        for elem in A_bit:
            count[len(A_bit)-j-1] += int(elem)
            j+=1
    total = 0
    for i in range(digs):
        total += ((2**i  % 1000000007) * count[i] * (N - count[i])) % 1000000007
        
    print(total % 1000000007)