MOD=10**9+7

N=int(eval(input()))

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

a_sum=sum(A)%MOD

ans=0

for a in A:

    a_sum-=a%MOD

    ans+=a_sum*a

    ans%=MOD

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

N=int(eval(input()))

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

ans=sum(A)**2

ans-=sum([x**2 for x in A])

ans//=2

print((ans%MOD))
MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
a_sum = sum(A) % MOD
ans = 0
for a in A:
    a_sum -= a % MOD
    ans += a_sum * a
    ans %= MOD
print(ans)

MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A) ** 2
ans -= sum([x**2 for x in A])
ans //= 2
print((ans % MOD))

-a_sum = sum(A) % MOD -ans = 0 -for a in A: -    a_sum -= a % MOD -    ans += a_sum * a -    ans %= MOD -print(ans) +ans = sum(A) ** 2 +ans -= sum([x**2 for x in A]) +ans //= 2 +print((ans % MOD))