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

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

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

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
val = sum(a[1:])

ans = 0
for i in range(n - 1):
    ans += a[i]*val
    ans %= 10**9 + 7
    val -= a[i + 1]
print(ans)
# Original solution
from sys import stdin, stdout
def gmi(): return list(map(int, stdin.readline().strip().split()))
def gms(): return list(map(str, stdin.readline().strip().split()))
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

n = gi()
ar = gari()
c = 0
ans = 0
for i in ar[:-1]:
    c += 1
    for j in ar[c:]:
        ans += i*j
print((ans%1000000007))








# Optimized solution
from sys import stdin, stdout
def gmi(): return list(map(int, stdin.readline().strip().split()))
def gms(): return list(map(str, stdin.readline().strip().split()))
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

n = gi()
ar = gari()
c = 0
ans = 0
s = sum(ar)
sub = 0
for i in ar[:-1]:
    sub +=  ar[c]
    ans += i*(s-sub)
    c += 1
print((ans%1000000007))
# Original solution
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        ai = A[0]
        aj = A[i + 1]
        ans[0] += ai * aj
    for j in range(1, N - 1):
        if A[j - 1] != 0:
            ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
        else:
            for k in range(j, N - 1):
                ai = A[k]
                aj = A[k + 1]
                ans[j] += ai * aj
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()

# Optimized solution
def calc(A, N, i):
    ans = 0
    ai = A[i]
    for i in range(i, N - 1):
        aj = A[i + 1]
        ans += ai * aj
    return (ans)


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        if A[i] != 0:
            ans[i] = calc(A, N, i)
            break
    for j in range(i + 1, N - 1):
        if A[j] != 0:
            ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
        else:
            ans[j] = 0
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
m = 10 ** 9 + 7
for i in range(N - 1):
    ans += A[i] * sum(A[i + 1:])
    ans %= m
print(ans)

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

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

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

for i in range(N-1):
    c+= A[i]* (sumA-A[i])
    sumA-= A[i]
print((c%(10**9+7)))
# Original solution
import itertools

N = int(eval(input()))
A_list = list(map(int, input().split()))
A_list.insert(0, 0)
product_dict = {}
for i, j in itertools.combinations(list(range(len(A_list))), 2):
    product_dict[str(i) + "&" + str(j)] = A_list[i] * A_list[j]

sum = 0
for i in range(1, N):
    for j in range(i + 1, N + 1):
        sum += product_dict[str(i) + "&" + str(j)]
        sum = sum % 1000000007
print(sum)


# Optimized solution
N = int(eval(input()))
A_list = list(map(int, input().split()))
A_list.insert(0, 0)

cum_sum = 0
cum_sum_list = []
for i in range(N + 1):
    cum_sum += A_list[i]
    cum_sum_list.append(cum_sum)

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

print(sm)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
sm=0
mod=10**9+7
s=sum(A)
for i in A:
    s-=i
    sm+=i*s
    sm%=mod
print(sm)
# Original solution
_ = eval(input())
nums = [int(x) for x in input().split(" ")]
res = 0
sums = [sum(nums[i:]) for i in range(1, len(nums))]
for i, ni in enumerate(nums[:-1]):
    res += ni*sums[i]
    res %= 10**9 + 7
print(res)

# Optimized solution
_ = eval(input())
nums = [int(x) for x in input().split(" ")]
res = 0
sums = []
for n in nums[1:][::-1]:
    if sums:
        sums.append(sums[-1]+n)
    else:
        sums.append(n)
sums.reverse()
#print(sums)
for i, ni in enumerate(nums[:-1]):
    res += ni*sums[i]
    res %= 10**9 + 7
print(res)
# Original solution

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

sum = 0
A.sort(reverse=False)

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

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

# Optimized solution

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


mod = 10**9+7
s = sum(A)

ans = 0

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

print((ans%mod))
# Original solution
import itertools

N = int(eval(input()))
A = list(map(int,input().split()))
#Aa=[]
#for i in A:
    #Aa.append(i%(10**9+7))
#print(Aa)
ans = 0

for i,j in itertools.combinations(A,2):
    #print(i,j)
    ans += i*j
    #print(ans)

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

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

MOD = 10**9+7
S = sum(A)
ans = 0

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

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

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

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = pow(10, 9) + 7
s = sum(a) % mod
ans = s * s % mod
for i in a:
    ans -= i * i
    ans %= mod
ans = ans * pow(2, mod - 2, mod) % mod
print(ans)
# Original solution
n = int(eval(input()))
a_list = list(map(int, input().split()))
ans = 0
m = 10 ** 9 + 7

for i in range(n):
    for j in range(i + 1, n):
        ans += a_list[i] * a_list[j]
        ans %= m

print(ans)


# Optimized solution
n = int(eval(input()))
a_list = list(map(int, input().split()))
sum_a = sum(a_list)
ans = 0
m = 10 ** 9 + 7

for i in range(n):
    sum_a -= a_list[i]
    ans += a_list[i] * sum_a
    ans %= m

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

sum_of_product = 0

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

print(sum_of_product)

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

sum_list = sum(A)
sum_of_product = 0

for i in A:
    sum_list -= i
    sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7)

print(sum_of_product)
# Original solution
from itertools import combinations

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

comb = combinations(a, 2)
res = 0
for i, j in comb:
  res += i*j
print((res%(10**9+7)))

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

ans = 0
summ = sum(lst)
summ_sq = summ**2
for i in range(n):
    ans += lst[i]**2

res = (summ_sq-ans)//2
print((res % ((10**9)+7)))
# Original solution
import math

class BitIndexedTree:
	'''NOTES: 1-origin-indexed
	'''
	def __init__(self, itemCount):
		self.itemCount = itemCount
		self.items = [0 for i in range(itemCount+1)]

	def add(self, i,value):
		while i <= self.itemCount:
			self.items[i] += value
			i += (i & (-i))

	def sumFromStart(self, end):
		summary = 0
		i = end
		while i > 0:
			summary += self.items[i]
			i -= (i & (-i))
		return summary

	def sum(self, start,end):
		summary = self.sumFromStart(end) - self.sumFromStart(start-1)
		return summary

if __name__ == "__main__":
	MOD = 10 ** 9 + 7
	N=int(eval(input()))
	A=list(map(int,input().split()))

	BIT=BitIndexedTree(N)

	for n in range(N):
		BIT.add(n+1, A[n])

	ans = 0
	for n in range(N-1):
		# print(A[n],BIT.sum(n+2,N),A[n] * BIT.sum(n+2,N))
		# print(MOD)
		ans += ((A[n] * BIT.sum(n+2,N)) % MOD)


	print((ans % MOD))








# Optimized solution

if __name__ == "__main__":
	MOD = 10 ** 9 + 7
	N=int(eval(input()))
	A=list(map(int,input().split()))

	Asum = sum(A) % MOD

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

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

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

print((ans % mod))

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

ans = 0

sum_j = [0] * n
sum_tmp = 0

for i in reversed(list(range(n))):
    sum_tmp += a[i]
    sum_j[i] = sum_tmp

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

print((ans % mod))
# Original solution
# from itertools import combinations
n=int(eval(input()))
a=[int(i) for i in input().split()]
pro=0
for i in range(n-1):
    for j in range(i+1,n):
        pro+=a[i]*a[j]
print((pro%(10**9+7)))

# Optimized solution
# from itertools import combinations
def Sum(A, n): 
    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 += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) // 2
n=int(eval(input()))
a=[int(i) for i in input().split()]
print((Sum(a,n)%(10**9+7)))
# Original solution
n = int(eval(input()))

a_list = list(map(int, input().split()))
s = 0
for i in range(n-1):
    for j in range(i+1, n):
        s += a_list[i] * a_list[j]

ans = s % 1000000007

print(ans)



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

a_list = list(map(int, input().split()))
sum_l = sum(a_list)
ans = 0
for i in range(n-1):
    sum_l -= a_list[i]
    ans += sum_l * a_list[i]
print((ans % 1000000007))
# Original solution
num=int(eval(input()))
date=list(map(int,input().split(" ")))
sum=0
for i in range(num):
    for j in range(num-i-1):
        sum+=date[i]*date[i+j+1]
print((sum%(10**9+7)))

# Optimized solution
num=int(eval(input()))
date=list(map(int,input().split(" ")))
sum0=0
sum1=0
for i in range(num):
    sum0+=date[i]
for i in range(num):
    sum0-=date[i]
    sum1+=date[i]*sum0
print((sum1%(10**9+7)))
# Original solution
N = int(eval(input()))
As = list(map(int, input().split()))

Asum = sum(As)

ans = 0
for index, A in enumerate(As):
    Asum = sum(As)
    ans += (A * (Asum - A))
    ans = ans % (10**9+7)

#    print(As)
    As = As[1:]
#    print(As)

print(ans)

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

Asum = sum(As)

ans = 0
for index, A in enumerate(As):
    ans += (A * (Asum - A))
    ans = ans % (10**9+7)
    Asum -= A
#    print(
#    print(As)

print(ans)
# Original solution
mod = 10 ** 9 + 7
N = int(eval(input()))
A = list([int(x) % mod for x in input().split(" ")])

print((sum((A[i] * A[j]) % mod for i in range(0,N-1) for j in range(i+1,N)) % mod))

# Optimized solution
mod = 1000000007
N = int(eval(input()))
A = list([int(x) % mod for x in input().split(" ")])

"""
累積話を計算しておく: O(N)
"""
_sum = 0
for i in range(N):
    _sum += A[i]
    _sum %= mod

"""
1重ループ内で下記を行う: O(N)

- 端のブロックを累積和から崩す（減算）
- 端のブロックと累積和をかける
- modをとる
"""
ans = 0
for i in range(N):
    # 累積和の端のブロックを崩す
    _sum -= A[i]

    ans += A[i] * _sum
    ans %= mod

print(ans)
# Original solution
m = 10**9 + 7
n = 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 += a[i]*a[j]

ans = ans%m

print(ans)

# Optimized solution
m = 10**9 + 7
n = eval(input())
a = list(map(int,input().split()))
ans = 0
s = sum(a)

for i in a:
  s -= i
  ans += s*i

ans = ans%m

print(ans)
# Original solution
import itertools
N = int(eval(input()))
A =  list(map(int, input().split()))
r = 0
m = 10**9+7
for x in itertools.combinations(A, 2):
    r += x[0]*x[1]
print((r % m))

# Optimized solution
import itertools
N = int(eval(input()))
A =  list(map(int, input().split()))
sa = sum(A)
r = 0
xx = sa
m = 10**9+7
for x in A:
    xx -= x
    r += x*xx
    r = r % m
print(r)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

bs = 10**9 + 7
sm = 0

for i, ai in enumerate(a):
    sm += (ai * sum(a[(i+1):])) % bs
    sm = sm % bs

print(sm)

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

bs = 10**9 + 7
s = sum(a)
sm = 0

for i, ai in enumerate(a):
    s -= ai
    sm += (ai * s) % bs
    sm = sm % bs

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

A_sum = sum(A)
ans = 0

for i in range(N-1):
    B = A.pop(0)
    A_sum -= B
    ans += A_sum*B
print((ans % (10**9+7)))


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

A_sum = sum(A)
ans = 0


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

print((ans%(10**9+7)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

ans = 0
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		acc = a[i] * a[j]
		ans += acc % MOD if acc >= MOD else acc
		ans %= MOD
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

sum_list = [0]
for i in range(n):
	sum_list.append((a[i] + sum_list[i]) % MOD)
# print(sum_list)

ans = 0
for i in range(len(a)):
	ans += a[i] * (sum_list[-1] - sum_list[i + 1])
	ans %= MOD

print(ans)
# Original solution
import itertools
n = int(eval(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:])%MOD))%MOD
print(ans)

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

    M = 10 ** 9 + 7

    combinations = [(i, j) for i in range(N-1) for j in range(i+1, N)]

    print((sum([A[i] * A[j] for (i, j) in combinations]) % M))


main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(n) for n in input().split()]

    M = 10 ** 9 + 7

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


main()
# Original solution
def main():
    N = int(eval(input()))
    A = [int(n) for n in input().split()]

    M = 10 ** 9 + 7

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


main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(n) for n in input().split()]

    M = 10 ** 9 + 7

    ans = 0
    cache = sum(A) % M
    for i in range(N-1):
        cache -= A[i]
        ans += A[i] * cache % M
    print((ans % M))


main()
# Original solution
# -*- coding: utf-8 -*-
def main():
    N = int(eval(input()))
    A  = [int(i) for i in input().split()]
    #ax = itertools.combinations(A, 2)
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans = (ans + A[i]*A[j]) % 1000000007
            #print(A[i],A[j],ans)
    print(ans)

if __name__ == "__main__":
    main()


# Optimized solution
# -*- coding: utf-8 -*-
def main():
    N = int(eval(input()))
    A  = [int(i) for i in input().split()]
    #N = 100000
    #A = [i for i in range(1,100000)]
    sum_a = sum(A)% 1000000007
    ans = 0
    for i in range(N):
        sum_a = (sum_a - A[i])% 1000000007
        ans = (ans + sum_a*A[i] ) % 1000000007
        #print((sum_a-A[i])*A[i]/2 ,ans)
    print(ans)
if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
inf = 10**9+7
aa = [0]*N

for i in range(N):
  aa[i] = A[i]**2
X = sum(A)**2 - sum(aa)
print(((X//2)%inf))

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


def main():
    n = int(eval(input()))
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    l = []
    for i in range(len(a)):
        l.append(i)

    c_list = list(itertools.combinations(l, 2))

    sm = 0
    for tpl in c_list:
        sm += (a[tpl[0]] * a[tpl[1]]) % (10**9+7)

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


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()

    sm = 0
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            sm += (a[i]% (10**9+7) * a[j% (10**9+7)]) % (10**9+7)
    
    print((sm% (10**9+7)))




if __name__ == '__main__':
    main()
# Original solution
def main():
    n = int(eval(input()))
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()

    sm = 0
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            sm += (a[i]% (10**9+7) * a[j% (10**9+7)]) % (10**9+7)
    
    print((sm% (10**9+7)))




if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    # d,t,s = map(int, input().split())
    a = list(map(int, input().split()))
    # s = input()
    mod = 10**9+7

    s = sum(a)

    sm = 0

    for i in a:
        s -= i
        sm += i * s % mod

    print((sm % mod))


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
nums = list(map(int,input().split()))

calcs = []
for i in range(N):
    a = nums[i]
    for j in range(i+1, N):
        calcs.append(a * nums[j])

print((sum(calcs) % (1000000000+7)))

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


total = 0
for i in range(N):
    a = nums[i]
    b = sum(nums[i+1:])
    total += a*b

print((total % (1000000000+7)))
# Original solution
N = int(eval(input()))
nums = list(map(int,input().split()))

def calc():
    total = 0
    for i in range(N):
        a = nums[i]
        b = sum(nums[i+1:])
        total += a*b
    return total

print((calc() % (1000000000+7)))


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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print((total % (1000000000+7)))
# Original solution
# from pprint import pprint
# import math
# import collections

n = int(eval(input()))
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

MOD = 10 ** 9 + 7

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

        # print(i, j, _)

print((sum % MOD))


# Optimized solution
# from pprint import pprint
# import math
# import collections

n = int(eval(input()))
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

MOD = 10 ** 9 + 7

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

# print('wa', wa)

ans = 0
j = 1
for i in range(n - 1):
    ttl = a[i] * wa
    ans += ttl

    wa -= a[j]
    j += 1

    # print('new wa', wa)

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

mod=10**9+7

ans=0

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

# Optimized solution
# AtCoder Beginner Contest 177
# C - Sum of product of pairs

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

mod=10**9+7

ans=0
accumls=[0]

for i in range (N):
    accumls.append(accumls[-1]+ls[i])

for i in range (N-1):
    ans+= ls[i]*(accumls[-1]-accumls[i+1])
    ans%=mod

print(ans)
# 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):]))

print((ans % mod))


# 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 - 1):
    total -= A[i]
    ans += (A[i] * total) 

print((ans % mod))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
a = [A for A in a if a != 0]
from itertools import combinations

MOD = 10**9 + 7
ans = 0
for i,j in combinations(a, 2):
    ans = ans + (i*j)%MOD

print((ans%MOD))

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

from itertools import accumulate
cumsum = list(accumulate(a[::-1]))[::-1]

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

from itertools import accumulate
cumsum = list(accumulate(a[::-1]))[::-1]

MOD = 10**9+7
ans = 0
for i,A in enumerate(a[:-1]):
    ans += A * cumsum[i+1]
    ans = ans % MOD
print(ans)

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

edge = sum(x)
print(((edge**2 - sum([X*X for X in x]))//2 % (10**9+7)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
s = 0

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

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


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

for i in range(n):
    a_sum += a[i]
    s.append(a_sum)

for i, j in enumerate(a):
    ans += j * (s[n - 1] - s[i])

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