# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
A = deque(list(map(int,input().split())))
tmp, ans = 0, 0

for i in range(N):
    tmp = A.popleft()
    for j in range(N - i - 1):
        ans += tmp ^ A[j]
print(ans % (pow(10,9) + 7))