from itertools import accumulate



n = int(eval(input()))

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

mod = 10 ** 9 + 7



ans, acc = 0, list(accumulate(a))

for i in range(n - 1):

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

    ans %= mod

print(ans)

n = int(eval(input()))

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

k = 0

num = sum(a)

import math



for i in range(n):

    reje = num - a[i]

    k += reje * a[i]



x = k//2

t = 10 ** 9 + 7

ans = x % t

print(ans)



from itertools import accumulate

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

n = int(eval(input()))
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    reje = num - a[i]
    k += reje * a[i]
x = k // 2
t = 10**9 + 7
ans = x % t
print(ans)

-from itertools import accumulate - -mod = 10**9 + 7 -ans, acc = 0, list(accumulate(a)) -for i in range(n - 1): -    ans += a[i] * (acc[-1] - acc[i]) -    ans %= mod +k = 0 +num = sum(a) +import math + +for i in range(n): +    reje = num - a[i] +    k += reje * a[i] +x = k // 2 +t = 10**9 + 7 +ans = x % t