n = int(input())
A = list(map(int, input().split()))
a = [bin(A[i]) for i in range(len(A))]
ans = []
anser = 0

for i in range(len(a)):
    for j in a[i]:
        a[i] = a[i].lstrip('0b')

for i in range(len(a)):
     a[i] = int(a[i])


for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        ans.append(a[i]^a[j])

ans = [str(ans[i]) for i in range(len(ans))]
ans = [int(ans[i], 2) for i in range(len(ans))]

ans = sum(ans)

print(ans/(10**9+7))

