import numpy as np

n=int(input())

a=[]

a= list(map(int,input().split()))

ans=0
anssub=0
tmpsum=0
a=np.sort(a)
for i in range(n-1):
    if a[i]!=a[i-1]:
        for k in range(i+1,n):
            tmp=a[i]^a[k]
            tmpsum=tmp+tmpsum
            #print(a[i])
            #print(a[k])
            #print('\0')
            ans=(ans+tmp)%1000000007

    else:
        ans=(ans+tmpsum)%1000000007
    if a[i]!=a[i+1]:
        tmpsum=0
print(ans)

