MOD = 10**9 + 7

n = int(eval(input()))

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

rs = [0]

for i in range(n):

    rs.append(rs[-1] + a[n - 1 - i])



ans = 0

for i in range(n - 1):

    ans += a[i] * rs[n - 1 - i] % MOD

print((ans % MOD))
MOD = 10**9 + 7

n = int(eval(input()))

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

ans, rem = 0, 0

for i in range(n - 1):

    rem += a[n - 1 - i] % MOD

    ans += a[n - 2 - i] * rem % MOD

print((ans % MOD))
MOD = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
rs = [0]
for i in range(n):
    rs.append(rs[-1] + a[n - 1 - i])
ans = 0
for i in range(n - 1):
    ans += a[i] * rs[n - 1 - i] % MOD
print((ans % MOD))

MOD = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
ans, rem = 0, 0
for i in range(n - 1):
    rem += a[n - 1 - i] % MOD
    ans += a[n - 2 - i] * rem % MOD
print((ans % MOD))

-rs = [0] -for i in range(n): -    rs.append(rs[-1] + a[n - 1 - i]) -ans = 0 +ans, rem = 0, 0 -    ans += a[i] * rs[n - 1 - i] % MOD +    rem += a[n - 1 - i] % MOD +    ans += a[n - 2 - i] * rem % MOD