CodeEff/ECCO huggingface dataset:
# Original solution
mod = 10**9 + 7
N = int(eval(input()))
array = [int(i) for i in input().split()]

output = 0
for i in range(N):
    for j in range(i+1, N):
        output += (array[i]%mod) * (array[j]%mod)
        
print((output%mod))

# Optimized solution
mod = 10**9 + 7
N = int(eval(input()))
array = [int(i) for i in input().split()]
array_2 = [0]

for a in array:
    array_2.append(array_2[-1]+a)
    
output = 0
for i in range(len(array)-1):
    output += array[i] * (array_2[-1] - array_2[i+1])
    
print((output%mod))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
_sum = 0

for i in range(N):
  for j in range(i+1, N):
    _sum += A[i] * A[j]

print((_sum % (10**9 + 7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
ak = 0
ak_2 = 0

for i in range(N):
  ak += A[i]
  ak_2 += A[i] ** 2
s = int(((ak ** 2) - ak_2) // 2)
print((s % mod))
# Original solution
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
data = [i for i in range(n)]

for i, j in itertools.combinations(data, 2):
    ans += (a[i] % mod)*(a[j] % mod) % mod

ans %= mod
print(ans)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
total = sum(a)
for i in range(n):
    total -= a[i]
    ans += a[i]*total
    ans %= mod
print(ans)
# Original solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    mod=10**9+7
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    ans=0
    for p in itertools.combinations(arr,2):
        ans=(ans+p[0]*p[1])%mod
    #ss=readline().rstrip()
    #yn(1)
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

# Optimized solution
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import copy

def yn(b):
    print(("Yes" if b==1 else "No"))
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    mod=10**9+7
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    arr2=copy.copy(arr)
    for i in range(1,n):
        arr2[i]=(arr2[i]+arr2[i-1])%mod
    base=arr2[n-1]+mod
    ans=0
    for i in range(n-1):
        ans=(ans+arr[i]*((base-arr2[i])%mod))%mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9+7
s = 0
for i in range(n-1):
    for j in range(i+1, n):
        s += (a[i]%mod*a[j]%mod)%mod
        s %= mod
print(s)
    

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9+7
s = 0
l = [0 for i in range(n)]
l[0] = a[0]
for i in range(1, n):
    l[i] += l[i-1]
    l[i]%=mod
    l[i] += a[i]
    l[i]%=mod
# print(l)
for i in range(1, n):
    s+=((a[i]%mod)*(l[i-1]%mod))%mod
    s%=mod
print(s)
# Original solution
N = int(eval(input()))
As = list(map(int,input().split()))
sums = 0
moder = 1000000007
for i in range(N-1):
  for j in range(N-i-1):
    sums+=(As[i]*As[i+j+1])%moder
print((sums%moder))

# Optimized solution
N = int(eval(input()))
As = list(map(int,input().split()))
sums = 0
moder = 1000000007
s=[0 for i in range(N-1)]
s[-1] = As[-1]
for i in range(N-2):
  s[-(i+2)] = s[-(i+1)]+As[-(i+2)]

for i in range(N-1):
  sums+= (As[i]*s[i])%moder
print((sums%moder))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
P = 0
A_l = [num% (10**9+7) for num in A]
 
for i in range(N):
  sum=0
  for j in range(i+1,N):
    sum += A_l[j]
  P += A_l[i]*sum
    
ans = P%(10**9+7)
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
P = 0
S = sum(A)
m = 10**9+7

for i in range(N):
  S -= A[i]
  P += A[i]*S
  
ans = P%m
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
s = sum(A)
ans = 0
for i in range(N):
    s = sum(A[i:N])
    s -= A[i]
    ans += A[i]*s
    
print((ans%((10**9)+7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

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

ans=(ans-s)//2
ans=ans%(10**9+7)



print(ans)


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
t=sum(a)
s=0
for i in range(n):
  s+=a[i]*a[i]

ans=(t*t-s)//2
ans=ans%(10**9+7)



print(ans)
# Original solution
D = 10 ** 9 + 7
N = int(eval(input()))
L= list(map(int, input().split()))

ans = L[0] * L[1] % D
for n in range(2,N):
  for l in range(n):
    ans += L[n] * L[l] % D

print((ans % D))


# Optimized solution
D = 10 ** 9 + 7
N = int(eval(input()))
L= list(map(int, input().split()))

ans = L[0] * L[1] % D
sub = L[0] + L[1]
for n in range(2,N):
    ans += L[n] * sub
    sub += L[n]
    
print((ans % D))
# Original solution
N=int(eval(input()))
Alist=list(map(int,input().split()))
sum=0
for i in range(N-1):
  for j in range((i+1),N):
    sum=(sum+(Alist[i]*Alist[j]))%(10**9+7)
print(sum)

# Optimized solution
N=int(eval(input()))
Alist=list(map(int,input().split()))
sum1=0
sum2=0
for i in range(N):
  sum1=sum1+Alist[i]
  sum2=sum2+(Alist[i])**2
ans=(sum1**2-sum2)//2
print((ans%(10**9+7)))
# Original solution
n=eval(input())
m=0
MOD = 10 ** 9 + 7
from itertools import combinations
b=combinations
a=b(list(map(int,input().split())),2)
for i,j in a:
    k=i*j
    m+=k%MOD
    m%=MOD
print(m)

# Optimized solution
N=int(eval(input()))
A=list(map(int, input().split()))
MOD = 10 ** 9 + 7

cumsum = [A[0]]
for i in range(1, N):
    cumsum.append(A[i] + cumsum[i - 1])

ans = 0
for i in range(N):
    ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD
    ans %= MOD

print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

result= 0

for j in range(0,n):
  result += a[j]*sum(a[j+1:n])

print((result%(10**9+7)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

result= 0
asum = sum(a)
for j in range(0,n):
  asum -= a[j]
  result += a[j]*(asum)

print((result%(10**9+7)))
# Original solution
a=int(eval(input()))
b = list(map(int, input().split()))
b.sort()
S=0

for i in range(0,a):
    S=S+b[i]*sum(b[i+1:a])
print((S % (10**9+7)))

# Optimized solution
a=int(eval(input()))
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    c=c-b[i]
    S=S+b[i]*c
print((S % (10**9+7)))
# Original solution
n = int(eval(input()))
list1 = list(map(int, input().split()))
s = 0
for i in range(n):
    p = list1[i] * sum(list1[i+1:n])
    s += p
print((s % (10**9 + 7)))

# Optimized solution
n = int(eval(input()))
list1 = list(map(int, input().split()))
s = 0
ss = sum(list1)
for i in range(n):
  a = list1[i]
  ss = ss - a
  p = a * ss
  s += p
print((s % (10**9 + 7)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
B = list([x%mod for x in A])
for i in range(N-1):
    for j in range(N):
        if i < j:
            ans = ans%mod + (B[i]%mod)*(B[j]%mod)
print((ans%mod))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
hoge = 0
mod = 10**9+7
for i in range(N):
    hoge = hoge + A[i]
    hoge = hoge % mod

for i in range(N):
    hoge = hoge - A[i]
    if hoge < 0:
        hoge = hoge + mod
    ans = ans + A[i] * hoge
    ans = ans % mod

print((ans%mod))
# Original solution
from sys import stdin
import itertools

def main():

    input = stdin.readline

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

    mod = (10 ** 9) +7

    ans = 0

    for i,j in itertools.combinations(list(range(N)),2):
        ans = (ans + (A[i] * A[j])) % mod

    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
from sys import stdin
import itertools

def main():

    input = stdin.readline

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

    mod = (10 ** 9) +7

    ans = 0

    total = sum(A)

    for i in range(N):
        total = total - A[i]
        ans = (ans + (A[i] * total)) % mod
        

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
import itertools

_ = eval(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

print((sum([(ai * aj) % mod for ai, aj in itertools.combinations(A, 2)]) % mod))


# Optimized solution
_ = eval(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

s = 0
a = 0
for _a in A:
  s += _a * a
  a = (a + _a) % mod
print((s % mod))
# Original solution
from itertools import *
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
a = combinations(list(range(N)),2)
for i in a:
    ans += A[i[0]] * A[i[1]]

print((ans % (10 ** 9 + 7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
s = [0]
for i in range(N):
    s.append(s[i] + A[i])
ans = 0
for i in range(N):
    ans += A[i] * (s[N] - s[i + 1])
print((ans % (10 ** 9 + 7)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

mod = 10**9+7
ans = 0
for i in range(N-1):
    ans += A[i] * sum(A[i+1:]) % mod
    ans = ans%mod
    
print(ans)

# Optimized solution

from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(accumulate(A))
mod = 10**9+7
ans = 0
sumA = sum(A)

for i in range(N-1):
    ans += A[i] * (sumA-B[i]) % mod
    ans = ans%mod
    
print(ans)
# Original solution
def resolve():
    import itertools

    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = itertools.combinations(A, 2)
    ans = 0
    for b in B:
        ans += b[0] * b[1]

    print((ans % (10**9 + 7)))

resolve()

# Optimized solution
def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    sm = sum(A) % (10**9 + 7)

    ans = 0
    for a in A:
        sm -= a
        ans += sm * a
        ans %= (10**9 + 7)
    print(ans)

resolve()
# Original solution
import itertools

def main():
	N = int(eval(input()))
	A = [int(a) for a in input().split(" ")]
	p = 1000000007
	ans = 0
	for c in itertools.combinations(A, 2):
		ans += (c[0] * c[1]) % p
		ans = ans % p
	print(ans)

main()

# Optimized solution
def main():
	N = int(eval(input()))
	A = [int(a) for a in input().split(" ")]
	p = 1000000007
	S = 0
	Asq = 0
	for i in range(len(A)):
		x = A[i]
		S += x % (2 * p)
		Asq += (x * x) % (2 * p)
	t = ((S * S) % (2 * p) - Asq) % (2 * p)
	print((int(t / 2)))

main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
mod = 10**9+7
P = 0
Q = 0

for i in range(N-1):
    for j in range(i+1, N):
        P = A[i] % mod
        Q = A[j] % mod
        ans += (P * Q) % mod
print((ans % mod))


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9+7
k = int((10**9 + 8)/2)
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
sum_1 = (sum_1)%mod

ans = sum - sum_1
ans = (ans*k)%mod

print(ans)
# Original solution
def sumPair(A):
    L = len(A)
    M = 1000000007
    total_sum = 0
    
    for i in range(0, L):
        for j in range(i+1, L):
            pair_m = A[i] * A[j]
            total_sum = (total_sum + pair_m) % M
    return total_sum
        

N = int(eval(input()))
A = list(map(int, input().rstrip().split()))
print((sumPair(A)))

# Optimized solution
def fastSumPair(A):
    L = len(A)
    M = 1000000007
    
    # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a)
    # derive from this equation
    
    # first array
    A_1_sum = 0
    for i in range(0, L):
        A_1_sum = (A_1_sum + A[i]) 
    
    A_1_sum = (A_1_sum ** 2) 
        
    # second array
    A_2_sum = 0
    for i in range(0, L):
        A_2_sum = (A_2_sum + A[i] ** 2) 
                  
    return int((A_1_sum - A_2_sum) // 2) % M        

N = int(eval(input()))
A = list(map(int, input().rstrip().split()))
print((fastSumPair(A)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1,N,1):
    ans += A[i]*A[j]
print((ans%(10**9+7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
tmp = sum(A[1:])
ans = 0
for i in range(N-1):
  ans += A[i]*tmp
  tmp -=A[i+1]
print((ans%(10**9+7)))
# Original solution
d = 10 ** 9 + 7
n = int(eval(input()))
lista = [int(x) for x in input().split()]
for k in lista:
    k %= d

total = 0
for i in range(n-1):
    for j in range(i+1, n):
        total += lista[i] * lista[j]
total %= d
print(total)


# Optimized solution
d = 10 ** 9 + 7
n = int(eval(input()))
lista = [int(x) for x in input().split()]
for k in lista:
    k %= d

totalJ = sum(lista)

total = 0
for i in range(n-1):
    totalJ -= lista[i]
    total += totalJ * lista[i]
total %= d
print(total)
# Original solution
MOD = 10 ** 9 + 7

n = int(eval(input()))
alst = list(map(int, input().split()))
total = sum(alst)
ans = 0
for a in alst:
    ans += a * (total - a)
    ans %= MOD
ans *= pow(2, MOD - 2, MOD)
ans %= MOD
print(ans)

# Optimized solution
n = int(eval(input()))
alst = list(map(int, input().split()))
ans = (sum(alst) ** 2 - sum([a ** 2 for a in alst])) // 2
MOD = 10 ** 9 + 7
print((ans % MOD))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        ans = (ans + (A[i] * A[j]) % 1000000007) % 1000000007
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

sum_a  = sum(A)
ans = 0
for i in range(len(A)):
    sum_a -= A[i]
    ans = (ans + (A[i] * sum_a) % 1000000007) % 1000000007
print(ans)
# Original solution
n = int(eval(input()))
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
res = 0
i = 0
j = 1
for i in range(n - 1):
  b = 0
  for j in range(i + 1, n):
    b += seq[j]
  res += (seq[i] * b) % a
print((res % a))

# Optimized solution
n = int(eval(input()))
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
s = sum(seq)
res = 0
for i in range(n - 1):
  s -= seq[i]
  res += (seq[i] * s) % a
print((res % a))
# Original solution
N = int(eval(input()))
A = [int(e) for e in input().split()]
sum = 0
asum = 0
for i in A :
    asum = asum + i*i
    for j in A:
        sum = sum + i*j
sum = ((sum - asum)/2)%1000000007

print((int(sum)))

# Optimized solution
N = int(eval(input()))
A = [int(e) for e in input().split()]

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print((sum%1000000007))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
for i in range(N):
    A[i]=A[i]%(10**9+7)
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans=(ans+A[i]*A[j])%(10**9+7)
print(ans)


# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
wa=[0]*(N-1)
wa[0]=A[-1]
for i in range(1,N-1):
    wa[i]=wa[i-1]+A[N-i-1]
ans=0
wa.reverse()

for i in range(0,N-1):

    ans=(ans+wa[i]*A[i])%(10**9+7)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
SUM = 0
for i in range(1,N):
    for j in range(i):
        SUM += A[i]*A[j]
print((SUM % (10**9+7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
sumA = sum(A)
SUM = 0
for i in range(1,N):
    sumA -= A[i]
    SUM += A[i]*sumA
print((SUM % (10**9+7)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

sm=0

for i in range(n-1):
  for j in range(i+1,n):
    b=a[i]*a[j]
    sm+=b
    sm=sm%((10**9)+7)

print(sm)


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))

sm=0
sumj=sum(a)

for i in range(n-1):
  sumj-=a[i]
  sm+=sumj*a[i]


print((sm%((10**9)+7)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
t = 0 
for i in range(len(A) - 1): 
        for j in range(i + 1, len(A)):
                t = (t + (A[i] * A[j])) % 1000000007
print(t)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
t = 0 
S = sum(A)
c = 0 
for i in range(len(A) - 1): 
        S -= A[i]
        t = (t + (A[i] * S)) % 1000000007
print(t)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
t = 0 
S = sum(A)
c = 0 
for i in range(len(A) - 1): 
        S -= A[i]
        t = (t + (A[i] * S)) % 1000000007
print(t)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
t = 0 
S = sum(A)
c = 0 
for i in range(len(A) - 1): 
        S -= A[i]
        t = (t + (A[i] * S))
print((t % 1000000007))
# Original solution
from itertools import combinations
N = int(eval(input()))
A = [int(i) for i in input().split(maxsplit=N)]
sumA = 0
for a, b in combinations(A, 2):
    sumA += (a * b) % (10**9 + 7)
print((sumA % (10**9 + 7)))


# Optimized solution
def resolve():
    N = int(eval(input()))
    A = [int(i) for i in input().split(maxsplit=N)]
    presum = [0 for _ in range(N + 1)]
    for i in range(N):
        presum[i + 1] = presum[i] + A[i]
    sumA = 0
    for i in range(1, N):
        sumA += (A[i] * (presum[i])) % (10**9 + 7)
    print((sumA % (10**9 + 7)))


resolve()
# Original solution
from itertools import combinations

N = int(eval(input()))
A = [int(n) for n in input().split()]
print((sum([i*j for i,j in combinations(A, 2)])%(10**9+7)))

# Optimized solution
N = int(eval(input()))
A = [int(n) for n in input().split()]
ans = 0
for i in range(0, N-1):
    ans += A[i]*sum(A[i+1:])
print((ans%(10**9+7)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
k = 0

for i in range(n - 1):
    for l in range(i + 1, n):
            k += a[i] * a[l]

x = k % (10 ** 9 + 7)
print(x)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
k = 0
num = sum(a)
t = 10 ** 9 + 7

for i in a:
    num -= i
    k += num * i

ans = k % t
print(ans)
# Original solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = 0
    m = 10 ** 9 + 7
    for i in range(n - 1):
        tmp_sum = sum(a[:i+1])
        ans += tmp_sum * a[i+1]
        if ans > m:
            ans = ans % m
    
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = 0
    m = 10 ** 9 + 7
    tmp_sum = 0
    for i in range(n - 1):
        tmp_sum += a[i]
        tmp_sum %= m
        ans += tmp_sum * a[i+1]
        ans %= m
    
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 +7
ans = 0

for i in range(len(a)-1):
    ans +=a[i]*(sum(a[i+1:len(a)]))
print((ans%mod))

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.reverse()
mod = 10**9 +7
ans = 0
S=[0]
for i in range(0,N):
    S.append(S[i]+a[i])
ans = 0
for j in range(len(a)):
    ans +=(a[j]*S[j])
print((ans%mod))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0
for i in range(0, N-1):
    for j in range(i+1, N):
        ans += A[i]*A[j]

print((ans % 1000000007))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(N-2, -1, -1):
    tmp += A[i+1]
    ans += A[i] * tmp

print((ans % 1000000007))
# Original solution
n = int(eval(input()))

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

sigma = 0
for i in range(len(a)-1):
  start = a[i]
  after = sum(a[i+1:])
  if after >= (10**9 + 7):
    after = after % (10**9+7)
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)


# Optimized solution
n = int(eval(input()))

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - a[i]
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)
# Original solution
n = int(eval(input()))

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - a[i]
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)


# Optimized solution
n = int(eval(input()))

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

sigma = sum(a)
count = 0
for i in range(len(a)-1):
  start = a[i]
  sigma = sigma-a[i]
  count = count + start * sigma
  if count >= 10**9+7:
    count = count % (10**9+7)

print(count)
# Original solution
import itertools
MOD = 1000000007

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

answer = 0
comb_list = list(itertools.combinations(A, 2))
for c in comb_list :
    answer += int(c[0]) * int(c[1]) 
print((answer % MOD))

# Optimized solution
MOD = 1000000007

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

answer = 0
s = sum(A)

for a in A:
    s -=a
    answer += (a * s)
print((answer%MOD))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
s = 0
for i in range(1,n):
    for j in range(i):
        pro = a[i] * a[j]
        s = s + pro

mod = s % (10**9 + 7)

print(mod)



# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
s = sum(a) ** 2
b = []
for i in range (n):
    b.append(a[i]**2)
s = (s - sum(b)) // 2
mod = s % (10**9 + 7)
print(mod)
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
MOD=1000000007
c=0
import itertools
a=list(itertools.combinations(A,2))
for i in range(len(a)):
  c+=(a[i][0]*a[i][1])
  c%=MOD
print(c)

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
MOD=10**9+7
c=0
for i in range(len(A)):
  c+=A[i]*(sum(A)-A[i])
print((c//2%MOD))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
MOD=10**9+7
c=0
for i in range(len(A)):
  c+=A[i]*(sum(A)-A[i]%MOD)
print((c//2%MOD))



# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
c=0
d=sum(A)
for i in range(0,N-1):
    d-=A[i]
    c+=A[i]*d
    if(c>10**9+7):
        c%=(10**9+7)
print(c)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
c=0
d=sum(A)
for i in range(0,N-1):
    d-=A[i]
    c+=A[i]*d
    if(c>10**9+7):
        c%=(10**9+7)
print(c)



# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
A2=0
for i in range(len(A)):
  A2+=A[i]**2
c=(sum(A))**2-A2
print((c//2%(10**9+7)))
# Original solution
from itertools import combinations
n=int(eval(input()))
num = list(map(int,input().split()))
ans = 0
for i in combinations(num,2):
  s = (i[0]*i[1])%(10**9+7)
  ans += s

new = ans%(10**9+7)
print(new)

# Optimized solution
n=int(eval(input()))
A = list(map(int,input().split()))
s=sum(A)
all=0
for i in A:
  s -= i
  all += (i*s)
ans=all%(10**9+7)
print(ans)
# Original solution
n = int(eval(input()))
a = [int(x) for x in input().split()]

ans = 0
for i in range(n-1):
    for j in range(n-1-i):
        if a[i] >= 1000000007:
            while a[i] >= 1000000007:
                a[i] = a[i] - 1000000007
            hoge = a[i] * a[i+1+j]
        elif a[i+1+j] >= 1000000007:
            while a[i+1+j] >= 1000000007:
                a[i+1+j] = a[i+1+j] - 1000000007
            hoge = a[i]*a[i+1+j]
        else:
            hoge = a[i] * a[i+1+j] % 1000000007
        while hoge >= 1000000007:
            hoge = hoge - 1000000007
        ans = ans + hoge

ans = ans % 1000000007
print(ans)

# Optimized solution
n = int(eval(input()))
a = [int(x) for x in input().split()]

s = sum(a)
ans = 0
mod = 10 ** 9 + 7

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

ans = ans % mod
print(ans)