#!/usr/bin/env python3
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
o = [[0] * (n + 1) for _ in range(80)]
x = [[0] * (n + 1) for _ in range(80)]
for b in range(80):
    for i in range(n):
        o[b][i + 1] += o[b][i]
        x[b][i + 1] += x[b][i]
        if a[i] >> b & 1 == 1:
            o[b][i + 1] += 1
        else:
            x[b][i + 1] += 1
li = []
nxt = 0
for b in range(80):
    c = 0
    for i in range(n):
        if a[i] >> b & 1 == 1:
            c += x[b][i]
        else:
            c += o[b][i]
    li.append((nxt + c) % 2)
    nxt = (nxt + c) // 2
ans = 0
for b in range(80)[::-1]:
    ans *= 2
    ans += li[b]
    ans %= MOD
print(ans)
