N=int(input())
A=list(map(int,input().split()))
B=[x for x in set(A)]
C=[x for x in set(A) if A.count(x) > 1]
ans=0
mod=(10**9)+7
for i in range(len(B)-1):
    for j in range(i+1,len(B)):
        if B[i] in C:
            if B[j] in C:
                ans+=4*(B[i]^B[j])
            else:
                ans+=2*(B[i]^B[j])
        else:
            if B[j] in C:
                ans+=2*(B[i]^B[J])
            else:
                ans+=B[i]^B[j]
ans=ans%mod
print(ans)
