n = int(input())
a = list(map(int, input().split()))
save = {}
ans = 0
tmp = 0

for i in range(n - 1):
    tmp = 0
    if i in save:
        ans += save[i]
    for j in range(i + 1, n):
        ans += a[i] ^ a[j]
        tmp += a[i] ^ a[j]

    save[i] = tmp

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