CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
prod_sum = 0
for i in range(n-1):
    for j in range(i+1, n):
        prod_sum += a[i]*a[j]
print((prod_sum%(10**9+7)))


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

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


sum = 0
D = set(range(N))
E = set()
for i in D:
    E.add(i)
    tmp = 0
    for j in D - E:
        tmp += A[j]
    sum += A[i] * tmp

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

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


S = []
sum = 0
for i in range(N):
    sum += A[i]
    S.append(sum)

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

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

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

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

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

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

# Optimized solution
#c
n = int(eval(input()))
a = list(map(int, input().split()))
import itertools
ans = 0

for i in range(len(a)-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()))

ans=0
inf=10**9+7
for i in range(N-1):
    if A[i]!=0:
        for j in range(i+1,N):
            ans+=A[i]*A[j]
        ans=ans%inf    
print(ans)

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

ans=0
inf=10**9+7
flag=True
for i in range(N-1):
    if A[i]!=0:
        for j in range(i+1,N):
            temp=(A[i]*A[j])%inf
            ans+=temp
            ans%=inf
 
          
print(ans)
# Original solution
def main():
    N=eval(input())
    A=list(map(int, input().split()))

    mod_value = 10**9 + 7
    sum_ = 0
    for i in range(len(A)-1):
        sum_ = (sum_ + A[i]*sum(A[i+1:])) % mod_value
    print(sum_)
main()

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

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print((sum_%mod_value))
main()
# Original solution
def readInt():
    return list(map(int, input().split()))

n = int(eval(input()))
a = readInt()

# print(n)
# print(a)
l = []
ans = 0
for i in a:
    i %= 10**9+7 
# print(a)

for i in range(n-1):
    for j in range(i+1,n):
        b = (a[i] * a[j]) % (10**9+7)
        l.append(b)
# print(l)

ans = sum(l) % (10**9+7)

print(ans)


# Optimized solution
def readInt():
    return list(map(int, input().split()))

n = int(eval(input()))
a = readInt()

# print(n)
# print(a)
b = 0
ans = 0
for i in a:
    i %= 10**9+7 
# print(a)

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

ans %= (10**9+7)

print(ans)
# Original solution
def readInt():
    return list(map(int, input().split()))

n = int(eval(input()))
a = readInt()

# print(n)
# print(a)
b = 0
ans = 0
for i in a:
    i %= 10**9+7 
# print(a)

s = sum(a)
s2 = sum([x**2 for x in a])

ans = (s**2 - s2 ) // 2

ans %= (10**9+7)

print(ans)


# Optimized solution
def readInt():
    return list(map(int, input().split()))

n = int(eval(input()))
a = readInt()
b = 0
ans = 0

for i in a:
    b += i ** 2

# print(sum(a))
ans = ((sum(a) ** 2 - b) // 2) % (10 ** 9 + 7)
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = int(1e9 + 7)
re = {}
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += a[i]*a[j]
        ans %= mod

print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = int(1e9 + 7)
ans, x = 0, 0
for i in range(n):
    ans += a[i]*x
    x += a[i]
print((ans%mod))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(n):
    b=(a[i]*sum(a[i+1:n]))%1000000007
    ans=ans+b
d=ans%(1000000007)
print(d)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
c=sum(a)
for i in range(n):
    c=c-a[i]
    b=(a[i]*c)
    ans=ans+b
d=ans%(1000000007)
print(d)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

A = list([x%(1*10**9 + 7) for x in A])


value = 0
plus = 0
ans = 0

for i in range(N-1):
    for j in range(N-i-1):
        value = (A[i]*A[i+j+1]+value) % (1*10**9 + 7)
        

print(value)

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

A_sum = sum(A)

value = 0
ans = 0

for i in range(N-1):
    A_sum -= A[i]
    value += A[i]*A_sum

ans = value % (1*10**9+7)

print(ans)
# Original solution
a = int(eval(input()))
alist = list(map(int, input().split()))
mod = 10**9+7
sumlist = []
ans = 0
for i in range(1, len(alist)+1):
    sumlist.append(sum(alist[0:i]))
for i in range(len(alist)):
    ans += alist[i]*(sumlist[-1]-sumlist[i])
print((ans%mod))

# Optimized solution
a = int(eval(input()))
alist = list(map(int, input().split()))
mod = 10**9+7
total = sum(alist)
sumlist = []
ans = 0
for i in range(len(alist)-1):
    total -= alist[i]
    ans += alist[i]*(total)
print((ans%mod))
# Original solution
N = int(eval(input()))
a_s = input().split(" ")
a_s = list(map(int, a_s))

mod = 10**9 +7
ans = 0
for i in range(len(a_s)-1):
  ans += (sum(a_s[i+1:])*a_s[i])%mod
  if ans > mod:
    ans = ans%mod
      
print(ans)

# Optimized solution
N = int(eval(input()))
a_s = input().split(" ")
a_s = list(map(int, a_s))
asum = sum(a_s)

mod = 10**9 +7
ans = 0
for i in range(len(a_s)-1):
  asum -= a_s[i]
  ans += (asum*a_s[i])%mod
  if ans > mod:
    ans = ans%mod
      
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))[::-1]
ans = 0
for _ in range(N-1):
    a = A.pop()
    ans += a * sum(A)
print((ans%(10**9+7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
prev = 0
s = []
for a in A:
    now = prev + a
    s.append(now)
    prev = now

start = 0
last = s[-1]
for i in s[:-1]:
    ans += (i - start) * (last - i)
    start = i
    
    
print((ans%(10**9+7)))
# Original solution
import math

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

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

# Optimized solution
import math

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

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

for v in itertools.combinations(A, 2):
    total += v[0]*v[1]
    #print(v)
print((total%(10**9+7)))

# Optimized solution
N = int(eval(input()))
A=list(map(int, input().split()))
B=[A[N-1]]
#print(B[0])
for i in range(len(A)-2):
    #print(i)
    b=B[i]+A[N-2-i]
    B.append(b)
#print(B)
total=0
for i in range(len(B)):
    total += A[i]*B[len(B)-1-i]

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

# Optimized solution
n=int(eval(input()))
data=list(map(int,input().split()))
num=0
ans=0
for i in range(len(data)):
    num+=data[i]
for i in range(len(data)):
    num-=data[i]
    temp=(num*data[i])
    ans+=temp
print((ans%(10**9+7)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

total = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        total += a[i] * a[j]
print((total % (pow(10, 9) + 7)))

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

s_1 = 0
s_2 = 0
m = 10 ** 9 + 7
for i in range(n):
    s_1 += a[i] % m
    s_2 += (a[i] ** 2) % m
s = (s_1 * s_1 - s_2) * pow(2, -1, m) % m
print(s)
# Original solution
import math
n=int(eval(input()))
a=list(map(int,input().split()))
mod=10**9+7

score=0
for j in range(n):
  i=0
  while i < j:
    score += a[i]*a[j]
    i += 1
print((score%mod))

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

# Optimized solution
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(eval(input()))
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)
 
result = (s1**2-s2)//2
print((result%m))
# Original solution
n = int(eval(input()))
arr = list(map(int, input().split()))
res = 0
for i in range(n):
    msum = 0
    if arr[i] != 0:
        for j in range(i+1, n):
            msum += arr[j]
        res += arr[i] * msum
res = res % (10**9 + 7)
print(res)
    


# Optimized solution
def findProductSum(A, n): 
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -
            individual_square_sum) // 2

n = eval(input())
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(res)
# Original solution
def execute(N, A):
    dst = 0
    for i in range(N-1):
        for j in range(i+1, N):

            dst += A[i] * A[j]

    return dst % (10**9+7)

if __name__ == '__main__':
    N = int(eval(input()))
    A = list(map(int, input().split()))

    print((execute(N, A)))

# Optimized solution
def execute(N, A):
    dst = 0
    s = sum(A)
    for v in A:
        s -= v
        dst += v * s

    return dst % (10**9+7)

if __name__ == '__main__':
    N = int(eval(input()))
    A = list(map(int, input().split()))

    print((execute(N, A)))
# Original solution
from itertools import combinations
n = int(eval(input()))
aList = list(map(int, input().split()))
comb = combinations(aList, 2)
ansSum = 0
for i in list(comb):
    ansSum += i[0]*i[1]
print((ansSum%(7+10**9)))

# Optimized solution
n = int(eval(input()))
aList = list(map(int, input().split()))
col = aList[:n-1]
row = aList[1:]
ansSum = 0
for i in range(n-1):
    for j in range(i,n-1):
        ansSum += col[i]*row[j]
print((ansSum % (7+10**9)))
# Original solution
n = int(eval(input()))
aList = list(map(int, input().split()))
col = aList[:n-1]
row = aList[1:]
ansSum = 0
for i in range(n-1):
    for j in range(i,n-1):
        ansSum += col[i]*row[j]
print((ansSum % (7+10**9)))

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

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

ans = ans % 1000000007

print(ans)

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

ans = 0
S = sum(A)
for i in range(N):
    S -= A[i]
    ans += A[i] * S

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

print((int(ans)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = sum(A)
cnt = 0
for i in range(N-1):
    B -= A[i]
    cnt += A[i]*B

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

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

for i in range(n):
    keisu[i] += sum(a[:i])


for i in range(n):
    ans += (a[i] * keisu[i])%(1000000000+7)

        
        

print((ans%(1000000000+7)))


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print((ans%(1000000000+7)))
# Original solution
n=int(eval(input()))
ans=0
mod=1000000007
list1=list(map(int ,input().split()))
for i in range(n):
  ans=ans+list1[i]*sum(list1[i+1:n])
    
print((ans%mod))

# Optimized solution
n=int(eval(input()))
ans=0
mod=10**9+7
list1=list(map(int ,input().split()))
sums=sum(list1)

for i in list1:
  sums -=i
  ans +=sums*i%mod
  
print((ans%mod))
# Original solution
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = list(map(int, read().split()))

    csum = [0]
    csum.extend(accumulate(A))

    ans = 0
    for i, a in enumerate(A):
        ans = (ans + a * (csum[N] - csum[i + 1]) % MOD) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = list(map(int, read().split()))

    total = sum(A)

    ans = 0
    for a in A:
        total -= a
        ans = (ans + a * total % MOD) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
def main():
	n = int(eval(input()))
	l = list(map(int, input().split()))
	_sum = 0
	for i in range(n):
		for j in range(i + 1, n):
			_sum += l[i] * l[j]
	mod = 10**9 + 7
	print((_sum % mod))

main()

# Optimized solution
def main():
	n = int(eval(input()))
	l = list(map(int, input().split()))
	a = sum(l)
	a *= a
	b = sum([i * i for i in l])
	a = (a - b) // 2
	mod = 10**9 + 7
	print((a % mod))

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

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

# Optimized solution
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)
# Original solution
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)

# Optimized solution
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)
# Original solution
n = int(eval(input()))
A = list(map(int,input().split()))
mod = (10**9) + 7
s = 0
for i in range(n-1):
    t = 0
    for j in range(i+1,n):
        t += A[j]%mod
    s += (A[i] * t)%mod
s = s%mod
print(s)

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

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

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

a=sum(A)
a=(a**2)

b=0
for i in range(n):
  b+=(A[i])**2
if a-b<0:
  c=a-b
  while c<=0:
    c+=mod
  
  ans=c//2
  ans=ans%mod

else:
  ans=(a-b)//2
  ans=ans%mod

print(ans)

# Optimized solution
n=int(eval(input()))
A=list(map(int,input().split()))
mod=10**9+7
INf=float('inf')

Acc=[0]*(n+1)
for i in range(1,n+1):
  Acc[i]=(Acc[i-1]+A[i-1])%mod

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

print((ans%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):
        sum+=a[i]*a[j]

ans=sum%(10**9+7)

print(ans)

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

ans = (x**2 - y)//2

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

print((int(ans)))
# Original solution
s = eval(input())
a = list(map(int,input().split()))
mod = 1000000007
ans = 0
while True:
    l_f = a[0]
    del a[0]
    if len(a) < 1: break
    for i in a:
        ans += l_f * i
print((ans%mod))

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

# Optimized solution
s = int(eval(input()))
a = list(map(int,input().split()))
mod = 10 ** 9 + 7
ans = 0
sum_a = sum(a)
for i in range(s):
    sum_a -= a[i]
    ans += sum_a * a[i]
print((ans%mod))
# Original solution
from itertools import combinations
mod = 10**9+7

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

ans = 0

for i,j in combinations(li,2):
    ans += (i*j)
    ans = ans%mod
print(ans)

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

S = sum(li)
li2 = [x**2 for x in li]
S2 = sum(li2)

print(((S**2-S2)//2%mod))
# Original solution
#整数値入力 1文字の入力
def input_one_number():
    return int(eval(input()))

#整数値龍力　複数の入力
def input_multiple_number():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

n = input_one_number()
a = input_multiple_number_as_list()

ssum =0
mod = 10**9+7
import itertools as itr
for i in itr.combinations(list(range(len(a))),2):
	ssum += a[i[0]]*a[i[1]]
	ssum %= mod
print(ssum)

# Optimized solution
#整数値入力 1文字の入力
def input_one_number():
    return int(eval(input()))

#整数値龍力　複数の入力
def input_multiple_number():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

n = input_one_number()
a = input_multiple_number_as_list()

mod = 10**9+7
ssum = 0

sumA = sum(a)

for _a in a:
	ssum += _a * (sumA-_a)

print((ssum//2%mod))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
ct = 0
for i in range(N-1):
    for j in range(i+1, N):
        x = A[i] * A[j]
        ct += x
print((ct % mod))


# Optimized solution
# C　Sum of product of pairs
N = int(eval(input()))
A = list(map(int, input().split()))
t = sum(A)
x = t - A[0]
mod = 10 ** 9 + 7
ct = 0
for i in range(N-1):
    ct += A[i] * x
    x = x - A[i+1]

print((ct % mod))
int((ct % mod))
# Original solution
mod =10**9 +7
n = int(eval(input()))
a = list(map(int, input().split()))
sumpro = 0

for i in range(n-1):
    x = 0
    for j in range(i+1, n):
        x += a[j]
    x = x%mod
    y = a[i]* x
    sumpro += y

print((sumpro%mod))

# Optimized solution
MOD = 10 ** 9 + 7  # MODは変数に入れてしまったほうが打ち間違えなくていいです

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

S = sum(A) % MOD
ans = 0

# A_Nも含まれてしまいますが、そのときはs=0なので問題ありません
for x in A:
    S -= x  # 自分と自分自身を掛けないように、先に引く必要があります
    S %= MOD  # MODはいちいち取っておくといいです
    ans += S * x
    ans %= MOD

ans %= MOD  # この行は完全に不要ですが、最後だけMODを取り忘れてWAになるミスは非常によくあるので、必要以上に取っておくと安心できます
print(ans)
# Original solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
MOD = 10**9 +7
s = 0
for i in range(n):
    for j in range(i + 1, n):
        s += (a[i]%MOD * a[j]%MOD)%MOD
print((s%MOD))

# Optimized solution
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum += A[i]
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = (array_sum * array_sum )
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += (A[i] * A[i]) 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    return (array_sum_square - individual_square_sum) // 2 
n = int(eval(input()))
a = [int(x) for x in input().split()]
MOD = 10**9 +7

print((int(findProductSum(a,n))%MOD))

# print(s%MOD)
# Original solution
N = int(eval(input()))
A = input().split()

for i in range(N):
    A[i] = int(A[i])

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

print((ans % 1000000007))

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

toA = 0
for i in range(N):
    A[i] = int(A[i])
    toA += A[i]

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

print((ans % 1000000007))
# Original solution
import sys
input = sys.stdin.readline

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


# Optimized solution
import sys
input = sys.stdin.readline
 
N = int(eval(input()))
A = list(map(int, input().split()))
score = 0
sum_A = sum(A)
for a in A[:-1]:
  sum_A -= a
  score += a * sum_A
print((score % (10**9+7)))
# Original solution
import sys
input = sys.stdin.readline

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

sum_A = sum(A)
ans = 0
for a in A[:-1]:
  sum_A -= a
  ans += a * sum_A

ans %= mod
print(ans)

# Optimized solution
import sys
input = sys.stdin.readline
 
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
 
sum_A = sum(A) % mod
ans = 0
for a in A[:-1]:
  sum_A -= a
  sum_A %= mod
  ans += a * sum_A
  ans %= mod

ans %= mod
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0
mod = 10**9 + 7

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

print((ans % mod))

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

ans = 0
mod = 10 ** 9 + 7
num = sum(A)

for a in A:
    num -= a
    ans += a * num

print((ans % mod))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
x=0
for i in range(N):
  x+=A[i]*(sum(A)-A[i])
print((x//2%1000000007))

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
x=0
x=sum(A)**2
for i in A:
  x-=i**2
print((x//2%1000000007))