MOD = 10 ** 9 + 7

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

bin_a = [bin(x)[2:] for x in a]

max_length = len(max(bin_a, key=len))

for ind, num in enumerate(bin_a):
    if len(num) < max_length:
        bin_a[ind] = '0' * (max_length - len(num)) + bin_a[ind]

# print(bin_a, max_length)

result = 0
for i in range(max_length-1, -1, -1):
    oc = sum([int(x[i]) for x in bin_a])
    zc = n - oc
    # print(oc, zc)
    # print(no_of_ones)
    result += oc * zc * (2 ** (max_length - i - 1))


print(result % MOD)
