import sys
def input():
    return sys.stdin.readline()[:-1]

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_sum_list = [0 for _ in range(max_bit)] #60
bit_list = [list() for _ in range(N)] #3* 10**5

for i in range(N): #3* 10**5
    bit_array = str(bin(A_list[i])[2:]).zfill((max_bit))
    
    for j in range(max_bit): #60
        inted_bit = int(bit_array[j])
        bit_sum_list[j] += inted_bit
        bit_list[i].append(inted_bit)
        
ans = 0

for i in range(N-1): #3* 10**5
    for j in range(max_bit):  #60
        if bit_list[i][j] == 0:
            ans += bit_sum_list[j] * 2**(max_bit - j - 1) % MOD_BY
        elif bit_list[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)