from itertools import accumulate



n = int(eval(input()))

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

s = list(accumulate(a))

MOD = 10 ** 9 + 7



ans = 0

for i in range(n):

    ans += a[i] * (s[n - 1] - s[i])

    ans %= MOD



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

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

MOD = 10 ** 9 + 7



s = sum(a) ** 2

t = sum(ai ** 2 for ai in a)

ans = (s - t) * pow(2, MOD - 2, MOD)

ans %= MOD

print(ans)
from itertools import accumulate

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

n = int(eval(input()))
a = list(map(int, input().split()))
MOD = 10**9 + 7
s = sum(a) ** 2
t = sum(ai**2 for ai in a)
ans = (s - t) * pow(2, MOD - 2, MOD)
ans %= MOD
print(ans)

-from itertools import accumulate - -s = list(accumulate(a)) -ans = 0 -for i in range(n): -    ans += a[i] * (s[n - 1] - s[i]) -    ans %= MOD +s = sum(a) ** 2 +t = sum(ai**2 for ai in a) +ans = (s - t) * pow(2, MOD - 2, MOD) +ans %= MOD