N = int(input())
A = list(map(int, input().split()))
ans = 0
prime = 10 ** 9 + 7
max_digit = len(bin(max(A))[2:])
A_bin = list(map(lambda x: bin(x)[2:].zfill(max_digit), A))
zero = [0] * max_digit
one = [0] * max_digit

for num in A_bin:
    for digit in range(max_digit):
        if num[-(digit + 1)] == '0':
            zero[digit] += 1
        else:
            one[digit] += 1

for digit in range(max_digit):
    ans += ((zero[digit] * one[digit]) % prime) * pow(2, digit, prime)
    ans %= prime

print(ans)
