N = list(map(int, eval(input())))

An = list(map(int, input().split()))

mnum = 10 ** 9 + 7

CumSum = An[0] % mnum

answer = 0

for i in range(1, len(An)):

    answer = (answer + CumSum * An[i]) % mnum

    CumSum = (CumSum + An[i]) % mnum

print(answer)
N = list(map(int, eval(input())))

An = list(map(int, input().split()))

mnum = 10 ** 9 + 7

CumSum = An[0]

answer = 0

for i in range(1, len(An)):

    answer = (answer + CumSum * An[i]) 

    CumSum = (CumSum + An[i])

print((answer%mnum))
N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10**9 + 7
CumSum = An[0] % mnum
answer = 0
for i in range(1, len(An)):
    answer = (answer + CumSum * An[i]) % mnum
    CumSum = (CumSum + An[i]) % mnum
print(answer)

N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10**9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
    answer = answer + CumSum * An[i]
    CumSum = CumSum + An[i]
print((answer % mnum))

-CumSum = An[0] % mnum +CumSum = An[0] -    answer = (answer + CumSum * An[i]) % mnum -    CumSum = (CumSum + An[i]) % mnum -print(answer) +    answer = answer + CumSum * An[i] +    CumSum = CumSum + An[i] +print((answer % mnum))