n=int(input())
a = list(map(int,input().split()))
ls = []
ls2 = []
ans = 0

for i in range(n-1):
    for j in range(i,n):
        p = a[i]^a[j]
        ls.append([a[i],a[j]])
        ls2.append(p)
        if [a[i],a[j]] in ls:
            ans+=ls2[ls.index([a[i],a[j]])]
        elif [a[j],a[i]] in ls:
            ans+=ls2[ls.index([a[j],a[i]])]
        else:
            ans+=p
        
print(ans%10**9)