N = int(eval(input()))

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





sum_a = sum(A)

ans = 0

mod = int(1e9+7)



for a in A:

    sum_a -= a

    ans += (sum_a * a) % 1000000007



ans %= 1000000007

print((int(ans)))

N = int(eval(input()))

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





sum_a = sum(A)

ans = 0

mod = int(1e9+7)



for a in A:

    sum_a -= a

    ans += (sum_a * a)



ans %= 1000000007



print((int(ans)))

N = int(eval(input()))
A = list(map(int, input().split()))
sum_a = sum(A)
ans = 0
mod = int(1e9 + 7)
for a in A:
    sum_a -= a
    ans += (sum_a * a) % 1000000007
ans %= 1000000007
print((int(ans)))

N = int(eval(input()))
A = list(map(int, input().split()))
sum_a = sum(A)
ans = 0
mod = int(1e9 + 7)
for a in A:
    sum_a -= a
    ans += sum_a * a
ans %= 1000000007
print((int(ans)))

-    ans += (sum_a * a) % 1000000007 +    ans += sum_a * a