import itertools
n = int(input())
a = sorted(map(int, input().split()))

sums = 0
for x in itertools.combinations(a, 2):
        r =int(bin(x[0] ^ x[1]), 2)
        sums += r

print(sums % (10**9 + 7))