N = int(input())
A = list(map(int, input().split()))
INF = 1000000007
keta = len(bin(max(A))) - 2
ans = 0
shift = 0
for _ in range(keta):
    num_1 = 0
    for a in A:
        if a&1:
            num_1 += 1
        a=a>>1
    ans += num_1 * (N-num_1) * 2 ** shift
    shift += 1
print(ans % INF)
