import numpy as np

MAX = 10**9+7

n = int(input())
l = input()
l = list(map(int, l.split()))
l = np.array(l, dtype=int)


ary = np.tril((l.reshape((-1,1))^l)) % MAX

ary = ary.sum(axis=0) % MAX

sum_xor = ary.sum() % MAX
sum_xor = int(sum_xor)

print(sum_xor)

