N = int(eval(input()))



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



MOD = 10 ** 9 + 7



x = 0

ans = 0

for i in range(len(A)):

    ans += A[i] * x % MOD

    x += A[i] % MOD

print((ans%MOD))    
N = int(eval(input()))



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



MOD = 10 ** 9 + 7



max_edge = sum(A)



tmp = 0



for num in A:

    tmp += num ** 2



print(((max_edge ** 2 - tmp) // 2 % MOD))
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
x = 0
ans = 0
for i in range(len(A)):
    ans += A[i] * x % MOD
    x += A[i] % MOD
print((ans % MOD))

N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
max_edge = sum(A)
tmp = 0
for num in A:
    tmp += num**2
print(((max_edge**2 - tmp) // 2 % MOD))

-x = 0 -ans = 0 -for i in range(len(A)): -    ans += A[i] * x % MOD -    x += A[i] % MOD -print((ans % MOD)) +max_edge = sum(A) +tmp = 0 +for num in A: +    tmp += num**2 +print(((max_edge**2 - tmp) // 2 % MOD))