n=int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans=0
for i in range(n-1):
    t = 0
    for j in range(i,n):
        if a[j-1]==a[j]:
            ans+=t
        else:
            ans+=a[i]^a[j]
            t=a[i]^a[j]
        
print(ans%10**9)