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

sum = 0
for i in range(n-1):
    tmp_sum = 0
    for j in range(i+1, n):
        tmp_sum += a[i] ^ a[j]
    sum += tmp_sum
print(sum % (10 ** 9 + 7))
