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


final_ans = 0
num = 1000000007
a.sort()

for i in range(n-1):
    if i != 0:
        if a[i] == a[i-1]:
            final_ans += ans
            final_ans %= num
            continue
        else:
            ans = 0
            for j in range(i+1, n):
                ans += (a[i] ^ a[j])
                ans %= num
            final_ans += ans
            final_ans %= num
    else:
        ans = 0
        for j in range(i+1, n):
            ans += (a[i] ^ a[j])
            ans %= num
        final_ans += ans
        final_ans %= num

print(final_ans)