import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = sum(a & 1)
    wa = (wa + b*(n-b)*(1<<i)) % kazu
    a = a >> 1

print(wa)