p = 10**9+7
N = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = (B[i-1]+A[i-1])%p
cnt = 0
for i in range(N-1):
    cnt = (cnt+A[i]^(B[N]-B[i+1]))%p
print(cnt)