n = int(eval(input()))

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



from itertools import accumulate

cumsum = list(accumulate(a[::-1]))[::-1]



MOD = 10**9+7

ans = 0

for i,A in enumerate(a[:-1]):

    ans += A * cumsum[i+1]

    ans = ans % MOD

print(ans)
n = int(eval(input()))

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



edge = sum(x)

print(((edge**2 - sum([X*X for X in x]))//2 % (10**9+7)))
n = int(eval(input()))
a = list(map(int, input().split()))
from itertools import accumulate

cumsum = list(accumulate(a[::-1]))[::-1]
MOD = 10**9 + 7
ans = 0
for i, A in enumerate(a[:-1]):
    ans += A * cumsum[i + 1]
    ans = ans % MOD
print(ans)

n = int(eval(input()))
x = list(map(int, input().split()))
edge = sum(x)
print(((edge**2 - sum([X * X for X in x])) // 2 % (10**9 + 7)))

-a = list(map(int, input().split())) -from itertools import accumulate - -cumsum = list(accumulate(a[::-1]))[::-1] -MOD = 10**9 + 7 -ans = 0 -for i, A in enumerate(a[:-1]): -    ans += A * cumsum[i + 1] -    ans = ans % MOD -print(ans) +x = list(map(int, input().split())) +edge = sum(x) +print(((edge**2 - sum([X * X for X in x])) // 2 % (10**9 + 7)))