import numpy as np 
# 初期入力
mod = 10**9 +7
ans =0
N =int(input())
A =list(map(int,input().split()))
A_np =np.array(A,dtype=np.int64)

# xor
for a in range(N-1):
    ans +=np.sum(A_np[a+1:] ^A[a]) %mod
print(ans %mod)