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

A.sort()
visited = {}

ans_all = 0

for i in range(N-1):
    if A[i] in visited:
        diff = len(visited[A[i]]) - (N-(i+1))
        ans_all += sum(visited[A[i]][diff:])
        visited[A[i]] = visited[A[i]][diff:]
    else:
        visited[A[i]] = []
        for j in range(i+1, N):
            # print(A[i], A[j])
            ans = A[i] ^ A[j]
            visited[A[i]].append(ans)
            ans_all += ans

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