N = int(input()) #3* 10**5
A_list = [int(e) for e in input().split()] #<=2**60

MOD_BY = 10**9 + 7
#愚直解だと 3* 10**5 C 2 ≒ 9 * 10**10 でTLEする。

#bit毎に考える
max_bit = len(bin(max(A_list))[2:])
bit_array = list()

for i in range(N): #3* 10**5
    bit_list = list(bin(A_list[i])[2:])
    bit_list = [int(i) for i in bit_list]
    
    if len(bit_list) < max_bit:
        bit_list = [0 for _ in range(max_bit-len(bit_list))] + bit_list

    bit_array.append(bit_list)

#print(bit_array)

bit_sum_list = [sum([row[i] for row in bit_array]) for i in range(max_bit)]
##print(bit_sum_list)

ans = 0
 
for i in range(N-1): #3* 10**5
    for j in range(max_bit):  #60
        if bit_array[i][j] == 0:
            ans += bit_sum_list[j] * 2**(max_bit - j - 1) % MOD_BY
        elif bit_array[i][j] == 1:
            ans += (N - i - bit_sum_list[j]) * 2**(max_bit - j - 1) % MOD_BY
            bit_sum_list[j] -= 1
        
        ans %= MOD_BY
print(ans)