from collections import Counter

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    a_sub = a[i+1:]
    a_sub_dict = dict(Counter(a_sub))
    for j in a_sub_dict.keys():
        ans += a_sub_dict[j] * (a[i] ^ j)
print(ans % mod)
