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