from collections import Counter
from itertools import combinations

N = int(input())
A = Counter(map(int, input().split()))

print(sum((a ^ b) * A[a] * A[b] for a, b in combinations(A, 2)) % (10**9+7))
