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, a in enumerate(a_ls):
    for j, x in enumerate(a[::-1]):
        if x == "0":
            res += 2 ** j * memo_ls[n-1-i][j]
        else:
            res += 2 ** j * (n - 1 - i - memo_ls[n-1-i][j])
        res %= MOD
print(res)