n = int(eval(input()))

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



b = 10**9+7

s = sum(a)

ans = 0

for i in range(n-1):

    s -= a[i]

    ans += a[i]*(s%b)

    ans %= b

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

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



s = sum(a)

b = 10**9+7

ans = 0

for i in a:

  s -= i

  ans += i*(s%b)

  ans %= b

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

n = int(eval(input()))
a = list(map(int, input().split()))
s = sum(a)
b = 10**9 + 7
ans = 0
for i in a:
    s -= i
    ans += i * (s % b)
    ans %= b
print(ans)

+s = sum(a) -s = sum(a) -for i in range(n - 1): -    s -= a[i] -    ans += a[i] * (s % b) +for i in a: +    s -= i +    ans += i * (s % b)