mod = 10 ** 9 + 7

def naive_main(nums):
    n = len(nums)
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += nums[i] ^ nums[j]
    return ans

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

# s

"""
0 0 0 1
0 0 1 0
0 0 1 0
0 1 0 0
1 0 0 0

4, 4, 6, 4

32 16 12 4
"""

max_len = len(bin(max(nums))) - 2

counter = [0 for _ in range(max_len)]
for i in range(n):
    ss = bin(nums[i])[2:]
    ss = "0" * (max_len - len(ss)) + ss
    for j in range(len(ss)):
        if ss[j] == "1":
            counter[j] += 1

# print(n)
# print(counter)
ans = 0
for i in range(max_len):
    c = counter[max_len - 1 - i]
    ans += (c * (n - c) * (2 ** i)) % mod

print(int(ans) % mod)
#print(naive_main(nums))

