
n = int(input())
ls = list(map(int,input().split()))
mod = 10**9 + 7
check = [[0]*61 for i in range(n+1)]
bit = [[False]*61 for i in range(n+1)]
index = n-1
for i in range(n,0,-1):
    c = ls[i - 1]
    co = 60
    wari = 2 ** 60
    check[i - 1] = [o for o in check[i]]
    while c > 0:
        check[i - 1][co] = check[i][co]
        if c < wari:
            co -= 1
            wari //= 2
            continue
        check[i - 1][co] += (c >= wari) + 0
        bit[i-1][co] = (c >= wari)
        co -= 1
        c %= wari
        wari //= 2

ans = 0
c = 0
for j in range(n - 1):
    c = 0
    for i in range(60):

        ans += (2 ** c) * check[j + 1][c] * ((not bit[j][c]) + 0) + (2 ** c) * (j + 1 - 1 - check[j + 1][c]) * ((bit[j][c]) + 0)
        c += 1
        ans %= mod
print(ans)