import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
ans=0
for i in range(N-1):
    ans+=sum(np.bitwise_xor.reduce([A[i+1:],np.full(len(A)-i-1,A[i],dtype=np.int64)]))
print(ans%(10**9+7))