N = int(input())
A = list(map(int, input().split()))
A.reverse()
sum = 0
xor = 0
cnt = [[0]*2]*N
for i in range(1, N):
    if A[i] in cnt:
        sum += cnt[A[i]][0]
        for j in range(cnt[A[i]][1], i):
            a = A[i] ^ A[j]
            xor += a
            sum += a
        cnt[A[i]][0] = xor + cnt[A[i]][0]
        cnt[A[i]][1] = i
    else:
        for j in range(i):
            a = A[i] ^ A[j]
            xor += a
            sum += a
        cnt[A[i]][0] = xor
        cnt[A[i]][1] = i
print(sum%1000000007)