peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

while s >= 2*(10**9 +7):
  s = int(s % 2*(10**9 +7))
s = s/2
 
print(int(s))
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
square = 0
for i in range(N):
    square += A[i] * A[i]
res = ((sumA * sumA - square)/2)%(1000000007)
print(int(res))
#-*- Coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]

l = 0
s = 0
for i in range(N):
    l += A[i]
    s += A[i]*A[i]
y = 0.5 * (l**2 - s)
print(int(y % (7+1e+9)))
N = int(input())
A = list(map(int, input().split()))

sum_tmp = sum(A)
mod = 10 ** 9 + 7
squ = 0
sum = 0

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

sum = (sum - squ) / 2
print(int(sum % mod))
n = int(input())
a = list(map(int,input().split()))
b = sum(a)**2
for i in range(n):
    b -= a[i]**2
print(int((b%(10**9+7))/2))
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  x+=a[i]
y=0
for j in range(1,n):
  y+=a[j]
w=0
for k in range(1,n-1):
  w+=a[k]**2
z=(x+y-w)//2
print(z%(10**9+7))
n=int(input())
x = [int(i) for i in input().split()]
s1=0
s2=0
for i in range (0,n):
  s1=s1+x[i]
  s2=s2+x[i]**2
s1=s1**2
ans=(s1-s2)
ans=ans/2
print(int(ans%1000000007))
N = int(input())
A = [int(x) for x in input().split()]

mod = 10**9 + 7

ans = sum(A) * sum(A) % mod
ans += mod - (sum([a*a for a in A]) % mod)
ans %= mod
print(ans//2)
import numpy as np
n = input()
a = input()
al = a.split()
a_l = [int(n) for n in al]
pr = np.prod(a_l)
print(pr % (10**9 + 7))
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  x+=a[i]
y=0
for j in range(1,n):
  y+=a[j]
z=x+y
print(z%(10**9+7))
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = 0
    q = 0
    for a in A:
        s += a % mod
        q += a ** 2 % mod
        s %= mod
        q %= mod
    ans = (((s * s) % mod - q) % mod) // 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()
N = int(input())
x = list(map(int, input().split()))
s = 0

for i in range(N-1):
  for j in range(i+1,N):
    s = s + x[i]*x[j] % 1000000007

print(s)
N = int(input())
ls = list(map(int, input().split()))
mod = 10**9+7
ans = 0
for num1 in ls:
    for num2 in ls:
        if num1 < num2:
            ans += num1*num2%mod
print(ans%mod)
N = int(input())
A = list(map(int,input().split()))
S = sum(A)
S2 = sum(map(lambda x:x**2,A))
 
print(int((S**2-S2)/2%(pow(10,9)+7)))
n=int (input())
a= list(map(int,input().split()))
s2=int(sum(a)*sum(a))
a2=[int(i*i) for i in a]
ans1=int((s2-sum(a2))/2)

print(int(ans1%(10**9+7)))
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    k = k + a[i] * num - a[i] ** 2

x = (k / 2) % (10 ** 9 + 7)
print(math.floor(x))
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2) % target)
N = int(input())
A = list(map(int, input().split()))

ans = 0
Q = 1e9 + 7

sumA = sum(A) % Q

for i in range(N-1):
    sumA -= A[i]
    sumA %= Q
    ans += sumA * A[i]
    ans %= Q

print(int(ans))
mod = ((10**9)+7)
def findProductSum(A, n): 
    array_sum = 0
    for i in A: 
        array_sum = (array_sum + i)%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in A: 
        individual_square_sum = (individual_square_sum + (i * i)%mod)%mod
    tmp = ((array_sum_square - individual_square_sum)%mod) // 2
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))
N = int(input())
A = list(map(int, input().split()))
S = 0
diag = 0
ans = 0
for i in range(N):
  S += A[i]
  diag = A[i] ** 2
  
for i in range(N):
  ans += S * A[i]
ans = ans - diag
print(ans % (10 ** 9 + 7))
N = int(input())
A = list(map(int,input().split()))
A = list(set(sorted(A)))
ans = 0
for i in range(len(A)-1):
    ans += (A[i] * sum(A[i+1::])) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % 10**9+7
print(ans)
def read_ints():
    return map(int, input().split(' '))


input()
a = list(read_ints())
s = sum(a)
ans = 0
mod = int(1e9 + 7)
for i in a:
    ans = (ans + i * (s - i)) % mod
print(ans // 2)
n = int(input())
a_list = list(map(int, input().split()))
ama_a = sum(a_list)
ans = 0
mod = 10**9+7
for i in a_list:
  ans+=i**2
ans = ama_a**2-ans
ans *= (mod+1)/2
ans %= mod
print(int(ans))
N = int(input())
A = input().split()

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

mod = 1000000007

ans = 0
tmp1, tmp2 = 0, 0

for m in A:
  tmp1 = (tmp1+m) %mod
  tmp2 = (tmp2+m*m%mod)%mod
  
ans = ((tmp1*tmp1)%mod-tmp2)%mod

if ans%2 ==0:
  ans = ans/2
else:
  ans =(ans+mod)/2

print(float(ans))
N = int(input())
A = [int(num) for num in input().split()]

A_sum = sum(A)
A2 = sum([num**2 for num in A])

res = (A_sum**2 - A2)//2
ans = res%(1e9+7)
print(int(ans))
import itertools

n = int(input())
A = list(map(int, input().split()))
Com = itertools.combinations(A,2)
ans = 0

for C in Com:
    ans += (C[0]*C[1]) % (10**9+7)

print(ans)
N=int(input())
A=list(map(int, input().split()))
a = 0
S = 0
for i in range(N):
    for j in range(i+1,N):
        a = A[i]*A[j]
        S += a
p = S%10000000007
print(p)
import numpy as np
N = int(input())
a = np.array(list(map(int,input().split())))
s1 = (a*a).sum()
s2 = a.sum()**2
S = (s2-s1)//2%(np.power(10,9)+7)
print(S)
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]




print(alst)
s=np.cumsum(alst)
print(s)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

S = sum(A)%mod
S = pow(S, 2, mod)
T = 0
for a in A:
    T+=pow(a, 2, mod)
    T %= mod

S -= T
S %= mod
S //= 2

print(S)
n = int(input())
a = [int(i) for i in input().split()]
total = sum(a)**2
ans = 0
m = 1e9+7
cur = sum([a[i]**2 for i in range(len(a))])
ans = (total-cur)/2
ans = ans%m
print(round(ans))
N = int(input())
A = list(map(int,input().split()))
S = 0
S2 = 0
MOD = 1000000007
for i in range(N):
  S += A[i]
  S2 += A[i]*A[i]
print((S*S-S2)/2%MOD)
# AtCoder Beginner Contest 177
# C - Sum of product of pairs

from itertools import combinations

N= int(input())
ls= list(map(int,input().split()))

mod=10**9+7

ans=0

for v in combinations(ls,2):
    print(v[0],v[1],v[0]*v[1],(v[0]*v[1]%mod))
    ans+= (v[0]*v[1])%mod
    ans%=mod

print(ans)
n = int(input())
a = list(map(int,input().split()))
m = 10**9+7

b = 0
c = 0
for i in range(n):
  b += a[i]**2/2%m
  c += a[i]

d = c**2/2 -b
ans = int(d%m)

print(ans)
n=int(input())
a=list(map(int,input().split()))
s=0
v=0
for i in range(n):
    s+=a[i]
    v+=(a[i]**2)%(10**9+7)
s=s%(10**9+7)
s_2=(s**2)%(10**9+7)
ans=(s_2-v)%(10**9+7)
print(ans//2)
import numpy as np


def main():
    n = int(input().strip())
    l = list(map(int, input().split()))
    l = np.array(l)

    tot = 0
    for i in range(n):
        tot += l[i] * (np.sum(l[i + 1:n], dtype='int64')) % (10 ** 9 + 7)

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


if __name__ == "__main__":
    main()
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
S=0
M=0
for i in A:
    S+=i
for i in A:
    M+=((S-i)*i)%mod
print(M%mod//2)
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2
        s %= mod
        sq %= mod
    s2 = (s**2) % mod

    ans = s2-sq
    if ans < 0:
        ans += mod
    print(ans//2)
resolve()
n = int(input())
a_list = list(map(int, input().split()))
ama_a = sum(a_list)
ans = 0
for i in a_list:
  ans+=i**2
ans = ((ama_a**2-ans)/2)%(10**9+7)
print(int(ans))
N = int(input())
A = list(map(int,input().split()))

sum_A = sum(A)

ans = 0
for i in range(N):
  a = A[i]
  sum_A-=a
  ans+=a*sum_A
print(ans)
import numpy as np
 
n = int(input())
a = input().split()
ai=np.array(a, dtype="int64")
 
div=1000000007
 
totalmod=(sum(ai)%div)**2
totalsho=(sum(ai)//div)
if (totalsho%2 == 1): totalmod=totalmod+div

diamod=0
for i in range(0,n):
  diagonalmod=(ai[i]**2)%div
  diagonalsho=(ai[i]**2)//div
  if (diagonalsho%2 == 1): diagonalmod=diagonalmod+div
  diamod=diamod+diagonalmod

ansmod=(totalmod-diamod)/2
if (ansmod <=0):
  kake=(-ansmod)//div+1
  ansmod=ansmod+kake*div
  
print(int((ansmod)%div))
N = int(input())
A_ls=list(map(int, input().split()))

a=(sum(A_ls))**2
for i in A_ls:
	a-=(i**2)

b=int(a/2)
print(b%(10**9+7))
#print(b)

# 2darray [[0] * 4 for i in range(3)]
# import itertools
N = int(input())

A = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    for m in range(i+1, N):
        sum += A[i]*A[m]

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

print(sum)
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
s,ss =0,0
for i in range(N):
    s += A[i]
    ss += A[i]**2
    s %= mod
    ss %=mod
a = int((s**2-ss)/2)
print(a%mod)
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = 0

#二乗和だけは1項ずつ求めてmodをとる
#for x in A:
#  sum += x
#  sum %= (10**9+7)
sum = A.sum() % (10**9+7)

sum2 = 0
#for x in A:
#  sum2 += x*x
#  sum2 %= (10**9+7)
B = np.square(A)
sum2 = B.sum() % (10**9+7)

ans = (sum**2 - sum2) % (10**9+7)
if ans < 0:
  ans += (10**9+7)
ans *= int((10**9+7+1)/2) 
ans %= (10**9+7)
print(int(ans))
N = int(input())
numbers = list(map(int, input().split()))
square = sum(numbers)**2
numbers_pow = sum(map(pow, numbers, [2]*N))
ans = (square - numbers_pow) / 2
print(int(ans % (1e9 + 7)))
N = int(input())
A = list(map(int, input().split()))

sum_of_power = (sum(A) ** 2) % 1000000007
power_of_sum = (sum([a ** 2 for a in A])) % 1000000007

ans = sum_of_power - power_of_sum

if ans < 0:
    ans += 1000000007

ans //= 2

print(ans)
# coding:utf-8
import numpy
n = int(input())
a = list(map(int, input().split()))
cum = numpy.cumsum(a)
# print(cum)
ans = 0
mod = 10**9 + 7

for i in range(n):
    ans += a[i] * (cum[-1] - cum[i])
    ans = ans % mod
print(ans)
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=0
for i in range(n-1):
  s-=a[i]
  ans+=a[i]*s
print(ans)
N = int(input())
As = list(map(int, input().split()))
S = 0
T = 0
for i in range(N):
  S += As[i]
  T += (As[i] * As[i]) % 1000000007
# print(S)
# print(T)
A = S*S % 1000000007
B = T % 1000000007
print(int(((A - B) % 1000000007) / 2) % 1000000007)
import copy

N = int(input())
A = [int(x) for x in input().split()]

partial_sum = copy.deepcopy(A)
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%(1e9+7)) %(1e9+7)
print(int(res))
n = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

sqsum = 0
asum = 0
for a in A:
  sqsum += a**2
  sqsum %= MOD
  asum += a
  asum %= MOD

ans = ((asum ** 2) - sqsum)
ans %= MOD

print(ans//2)
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,1,3,6,10,15,21]

s=np.cumsum(alst)

s=list(s)
sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)
from itertools import product
n=int(input())
l=list(map(int,input().split()))
m=list(product(l,l))
N=(10**9)+7
ans=0
for i in range(len(m)):
    if m[i][0]!=m[i][1] and m[i][0]<m[i][1]:
        ans+=m[i][0]*m[i][1]

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


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod =10**9+7

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

    ss =sum(A) %mod
    sm =ss *ss % mod
    for i in A:
        sm -= i*i
        sm %=mod
    sm //= 2
    sm %=mod
    print(sm)






if __name__ == "__main__":
    main()
n = int(input())
a = list(map(int, input().split(" ")))
mod = 10 ** 9 + 7
s = (sum(a) % mod) ** 2
s %= mod
sq = 0
for i in range(n):
    sq += (a[i] ** 2) % mod
    sq %= mod
s -= sq
s%=mod
s /= 2
print(int(s % mod))
import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()
mod=10**9+7
sum_a=sum(A)

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

print(ans//2)
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
A = 0
B = 0
for i in range(n):
    A += a[i]
    B += a[i] ** 2
    B %= mod
A %= mod
A2 = A**2 % mod
ans = (A2 - B) % mod
ans //= 2
print(ans)
n=int(input())
A=list(map(int,input().split()))
print(A)

seki=0
for i in range(n-1):
  for j in range(i+1,n):
    seki=seki+A[i]*A[j]
print(seki%1000000007)
n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
t = (sum(item)**2 - sum([i**2 for i in item])) / 2
t = int(t)
print(t % mod)
n = int(input())
a = list(map(int, input().split()))
b = sum([(i**2)%(10**9+7) for i in a])#%(10**9+7)
print(((sum(a)%(10**9+7))**2-b)%(10**9+7)//2)
n = int(input())
a=list(map(int,input().split()))
sum=0

for i in a:
    for j in a:
        if(i!=j):
          sum += i*j

print(sum/2%(1000000000+7))
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    n = int(input())
    As = list(map(int, input().split()))

    mod = 10**9+7
    _sum = 0
    for a in As:
        _sum += a
        _sum %= mod

    total = 0
    for a in As:
        total += a * (_sum - a)
        total %= mod

    total //= 2

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()
n = int(input())
A = list(map(int, input().split()))
Sum = sum(A)
square_sum = sum(map(lambda x:x**2, A))
print((Sum - square_sum)//2)
n = int(input())
a = list(map(int, input().split(" ")))

res = 1
for j in range(n):
    for i in range(j+1):
        res = res * a[j] * a[i] % ((10**9) + 7)
print(res)
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

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

print(ans)
import numpy as np
n = int(input())
a = list(map(int, input().split()))
s1 = sum(a)
a2 = np.array(a,dtype=int)
a3 = a2**2
s2 = sum(a3)
print(((s1**2-s2)//2)%(10**9+7))
n = int(input())
A = list(map(int, input().split()))

AA = sum(A)
ans = 0
mod = 10**9 + 7
for i in range(n):
    ans += (A[i] % mod * (AA - A[i]) % mod) % mod
if ans//2 < mod:
    print(ans % mod//2)
else:
    print((ans//2) % mod)
n = int(input())
a = list(map(int,input().split()))

mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod

for i in range(n):
    sum_a2 -= (a[i]**2)
    sum_a2 %= mod
    
ans = sum_a2//2

print(ans)
N=int(input())
A=list(map(int, input().split()))
s=0
for i in range(N):
  s+=A[i]*A[i]
m=sum(A)
k=(m*m-s)/2
print(int(k%(10**9+7)))
mod = (10**9)+7
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = (array_sum + A[i])%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum = (individual_square_sum + (A[i] * A[i])%mod)%mod
    tmp = (((array_sum_square - individual_square_sum)%mod) // 2)%mod
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))
n = int(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))
N = int(input())
A = list(map(int, input().split(" ")))
res = 0
for i in range(N):
    for j in range(i+1, N):
        res = res + ((A[i]*A[j]) % 1000000007)
print(res)
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [float(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0.0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2) % target)
n = int(input())
arr=list(map(int, input().split()))



array_sum = 0
for i in range(0, n, 1): 
    array_sum = array_sum + arr[i] 
  
array_sum_square = array_sum * array_sum 
  
individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum += arr[i] * arr[i] 
  
b=(array_sum_square-individual_square_sum)%1000000007
b=int(b)
b=b/2;
b=int(b)
print(b)
MOD  = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum = (array_sum + a[i] )

array_sum_square = (array_sum * array_sum )

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum = (individual_square_sum+(a[i] * a[i]))

ans=(array_sum_square - individual_square_sum) / 2
print(int(ans%MOD))
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]

y = ((z % 1000000007)** 2) % 1000000007

x = 0
for j in range(n):
    x += a[j] ** 2


p = int(((y - x) / 2) % 1000000007)
print(p)
m=int(input(""))
L=[int(i) for i in input().split(" ")]
tot=int(0)
total=sum(L)
for i in range(m):
    total-=L[i]
    tot+=L[i]*total
print(tot)
MOD = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum += a[i]
    array_sum%=MOD

array_sum_square = pow(array_sum,2,MOD)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2,MOD)
    individual_square_sum%=MOD

ans=(array_sum_square - individual_square_sum+MOD) / 2
print(int(ans%MOD))
n = int(input())
s = list(map(int, input().split()))

total = 0 

for i in range(len(s)-1):
  for j in range(i+1, len(s)):
    total += s[i] * s[j]

print(total)
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
s = sum(a) % mod
ans = 0
for x in a:
  ans += (s-x) * x
  ans %= mod
print(ans//2)
n=int(input())
a=list(map(int,input().split()))

mod=10**9+7
total = sum(a)
cum=[]

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

print(ans)
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

mod = 10 ** 9 + 7

sumlist= sum(a)
x = []
for i in range(n):
    x.append(sumlist - a[i])

ans = 0
for i in range(n):
    ans += (a[i] * x[i])
    ans %= mod

print(ans // 2)
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

b = 0
c = 0
for i in range(n):
  b += a[i]**2
  c += a[i]

d = (c**2 - b)/2
ans = int(d%mod)

print(ans)
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    reje = num - a[i]
    k += reje * num

x = math.floor(k / 2)
t = 10 ** 9 + 7
ans = x % t
print(ans)
N = int(input())
A = list(map(int,input().split()))

Sum = sum(A)

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

ans %= 1000000007

print(int(ans/2))
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A_array = np.array(A)

# i = j
ij = np.sum(A_array * A_array)

Acum = np.sum(A_array)

temp = 0
for i in A:
    temp += (i*Acum - i**2)/2 % (10**9 + 7)

print(int(temp) % (10**9 + 7))
import numpy as np

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

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

mod = 10**9 + 7

A = np.array(A)

sum1 = A.sum()
sum2 = (A**2).sum()

ans = (sum1**2 - sum2) //2

print(ans%mod)
import numpy as np
import copy

N = int(input())
h = list(map(int, input().split()))
h.sort(reverse=True)
h2 = copy.copy(h)
ans = 0
s = np.sum(h2)
for i in range(N):
    s -= h[i]
    ans += h[i] * s
ans = ans % (10 ** 9 + 7)
print(int(ans))
from sys import stdin

n = stdin.readline().rstrip().split()[0]
A = [int(x) % (10 ** 9 + 7) for x in stdin.readline().rstrip().split()]

print(int((sum(A)**2 - sum([a**2 for a in A])) / 2) % (10**9 + 7))
from itertools import *
N = int(input())
A = list(map(int,input().split()))
ans = 0
a = combinations(range(N),2)
for i in a:
    ans += A[i[0]] * A[i[1]]

print(ans)
n=int(input())
a=list(map(int, input().split()))
mod=10**9+7
ans=((sum(a)%mod)**2)%mod
for i in range(n):
  ans-=a[i]**2
  ans%=mod
print(ans//2%mod)
n = int(input())
numbers = list(map(int, input().split()))
numbers = [i % 1000000007 for i in numbers]

sum = 0
for i in range(n):
    for j in range(i + 1, n):
        sum += (numbers[i] * numbers[j]) % 1000000007
print(sum)
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(N):
  s += a[i]

s = s*s

for i in range(N):
  s -= a[i]*a[i]

s = int(s/2)

while s >= 10**9 +7:
  s = s % (10**9 +7)

print(int(s))
N = int(input())
A = list(map(int, input().split()))
sum_A = sum(A)
ans = 0

for i in range(N):
  sum_A = sum_A - A[i]
  ans += A[i] * sum_A
  
print(ans//(10^9 + 7))
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

s = int(s/2)
if s >= 10**9 + 7:
  s = s +49

while s >= (10**9 +7):
  s = int(s % (10**9 +7))

print(int(s))
from numba import jit
@jit
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(n-1):
    ans=ans+(a[i]*(sum(a[i+1:n])%mod))%mod
  print(ans)
main()
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A)
    q = sum([a ** 2 for a in A])
    ans = (((s * s) - q)) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()
import numpy as np

n = int(input())

al = list(map(int, input().split()))
bl = np.cumsum(al)
ans = 0
for i in range(n):
    ans += al[i]*bl[i]-al[i]**2

mod = 10**9+7
print(ans%mod)
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
for i in range(len(a)):
  s += a[i]
for i in range(len(a)-1):
  s -= a[i]
  if s<0:
    s += 1e9+7
  ans += s*a[i]
  ans %= 1e9+7
print(int(ans))
N = int(input())
A_n = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

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

print(ans % mod)
a = input()
import numpy as np
b = list(map(int,input().split()))
b = np.array(b)
m = 10**9 + 7
total = int((sum(b)**2 - b.dot(b))/2)

print(total%m)
n = int(input())
i_j_list = list(map(int, input().split()))

total = 0
for i,v in enumerate(i_j_list):
  for j in range(i,len(i_j_list)):
    if i < i_j_list[j]:
      total += i * i_j_list[j]
ans = total % (10**9 + 7)
print(ans)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
f = sum(a)%mod
ans = 0
for i in range(n):
  e = (f-a[i])%mod
  ans+= (e*a[i])%mod
  ans%=mod
print(ans//2)
N = int(input())
A = list(map(int, input().split()))
SUM = 0
startpoint=0

for i in range(len(A)):
    for j in range(i+1,len(A)):
        
        SUM = SUM+( A[i] * A[j])
        
print(SUM)
n = int(input())
a = list(map(int,input().split()))

sums = 0
for i in range(n):
    sums += a[i]

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans /= 2
ans %= 1000000007
print(int(ans))
import numpy as np

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