import numpy as np
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
mod = 10**9+7

ans = 0
one = np.zeros(60, dtype=int)

for i in range(n):
    b = bin(a[i])[2:].zfill(60)

    for j in range(60):
        if b[j] == "1":
            ans += pow(2, 60-j-1, mod)*(i-one[j])
        else:
            ans += pow(2, 60-j-1, mod) * one[j]
        ans %= mod

    one += np.array(list(map(int, list(b))))

print(ans)
