import sys
n = int(input())
a_ls = [bin(int(i))[2:].zfill(60) for i in sys.stdin.readline().split()]
MOD = 10**9 + 7
#memo_ls[i][j] : 後ろからi番目まででj桁に1がある個数
memo_ls = [[0 for j in range(60)] for i in range(n+1)]
for i, a in enumerate(a_ls[::-1], 1):
    for j, k in enumerate(a[::-1]):
        memo_ls[i][j] = memo_ls[i-1][j] + int(k)

res = 0
for i in range(60):
    res += memo_ls[-1][i] * (n - memo_ls[-1][i]) * 2 ** i
    res %= MOD
print(res)