n=int(eval(input()))

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

suml=sum(l)

num=0

for i in range(n-1):

    suml-=l[i]

    num+=(l[i]*suml)%(10**9+7)

print((num%(10**9+7)))
n=int(eval(input()))

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

suml=sum(l)

num=0

for i in range(n):

    num+=l[i]**2

print(((suml**2-num)//2%(10**9+7)))

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

n = int(eval(input()))
l = list(map(int, input().split()))
suml = sum(l)
num = 0
for i in range(n):
    num += l[i] ** 2
print(((suml**2 - num) // 2 % (10**9 + 7)))

-for i in range(n - 1): -    suml -= l[i] -    num += (l[i] * suml) % (10**9 + 7) -print((num % (10**9 + 7))) +for i in range(n): +    num += l[i] ** 2 +print(((suml**2 - num) // 2 % (10**9 + 7)))