import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
b = 0
num = 1000000007
N_1 = N.pop(-1)
N_2 = N.pop(0)
for i in N_1:
    for j in N_2:
        b += N_1 ^ N_2
print(b%num)
