N = int(input())
A = list(map(int, input().split()))
A.reverse()
sum = 0
check = []
num = []
sub = []
a = subb = 0
for i in range(1, N):
    sub_sum = 0
    if A[i] in check:
        a = check.index(A[i])
        for j in range(num[a], i):
            sub_sum += A[i] ^ A[j]
        subb = sub_sum + sub[a]
        sum += subb
        sub[a] = subb
    else:
        check.append(A[i])
        num.append(i)
        for j in range(i):
            sub_sum += A[i] ^ A[j]
        sum += sub_sum
        sub.append(sub_sum)
print(sum%1000000007)