N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

lists = [[] for i in range(len(A))]

_a = A[0]
li = [0 for i in range(61)]
for i in range(len(li))[::-1]:
    quo = _a // pow(2, i)
    li[i] = quo
    _a -= quo*pow(2, i)
lists[0] = li

for i in range(1, len(A)):
    _a = A[i]
    li = [0 for j in range(61)]
    for j in range(len(li))[::-1]:
        quo = _a // pow(2, j)
        li[j] = lists[i-1][j] + quo
        _a -= quo*pow(2, j)
    lists[i] = li

res = []
for j in range(len(A)-1):
    a = A[j]
    lia = [lists[len(lists)-1][i] - lists[j][i] for i in range(61)]
    if j == 0:
        lib = lists[0]
    else:
        lib = [lists[j][i] - lists[j-1][i] for i in range(61)]
    _res = 0
    for i in range(len(li)):
        if lib[i] % 2 == 0:
        # 0のとき
            _res += pow(2, i) * lia[i]
        else:
        # 1のとき
            _res += pow(2, i) * ((N-j-1) - (lia[i]))
        _res %= MOD
    res.append(_res)
print(sum(res) % MOD)
