import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
B = [(format(a, '0{}b'.format(bit)))[::-1] for a in A]
ans = 0
for i in range(bit):
    nb_1 = sum([int(b[i]) for b in B])
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)