n = int(input())
a = [int(i) for i in input().split()]
t = []
mod = (10 ** 9) + 7
count = 0
while sum(a) > 0:
    t.append(sum([1 & i for i in a]))
    a = [i >> 1 for i in a]
    count += 1
ans = 0
for i, j in zip(t, range(count)):
    ans += i * (n - i) * (2 ** j)
    ans = ans % mod
print(ans)