peterverebics/CodeNet_Python_118 huggingface dataset:
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)
N = int(input())
A = list(map(int, input().split()))

ans = 0
mod = int(1e9 + 7)
s = sum(A) % mod

for a in A:
    s -= a
    ans += (a * s) % mod
    ans %= mod

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

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

print(ans%mod)
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
S = 0
for i in range(N):
    S += A[i]

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

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

sum_A = sum(A)
ans = 0

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

print(ans%mod)
def modinv(val, mod):
    b, u, v = mod, 1, 0
    while b:
        t = val // b
        val = val - t * b
        val, b = b, val
        u = u - t * v
        u, v = v, u
    u = u % mod
    return u


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
total = 0
for item in a:
    total = (total + item) % mod

total = (total * total) % mod

for item in a:
    total = (total - (item * item)) % mod

print(total * modinv(2, mod) % mod)
n = int(input())
a = list(map(int, input().split()))
ans = 0
c = sum(a)

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

print(ans % (10 ** 9 + 7))
N = int(input())
A = list(map(int,input().split()))
tasizann = 0
for i in range (N):
 tasizann = tasizann + A[i]
nijou = tasizann**2
nijouwa = 0
for i in range (N):
 nijouwa =nijouwa + A[i]**2
ans = (nijou - nijouwa)//2
ans = ans % (10**9+7)
print (ans)
import itertools
n = int(input())
a = list(map(int,input().split()))
cumsum = list(itertools.accumulate(a))
ans = 0
mod = 10**9+7
for i in range(1,n):
  ans += a[i]*cumsum[i-1]
print(ans%mod)
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()
n = int(input())
a_array = map(int, input().split())
MOD = 10 ** 9 + 7
a_array = [a % MOD for a in a_array]
sum = 0
square_sum = 0
for i in range(n):
    sum += a_array[i]
    sum %= MOD
    square_sum += pow(a_array[i], 2, MOD)
    square_sum %= MOD

ans = pow(sum, 2, MOD) - square_sum
ans *= 500000004
ans %= MOD
print(ans)
import sys

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

    sum_A = sum(A)
    cum_A = [sum_A]
    for a in A[:N-1]:
        cum_A.append(cum_A[-1] - a)

    res = 0
    mod = 1000000007
    for i, a in enumerate(cum_A[1:]):
        res += A[i] * a
        res %= mod

    print(res)

if __name__ == "__main__":
    main()
n = int(input())
list1 = list(map(int,input().split()))

mod = 10 ** 9 + 7
total = 0
y = sum(list1)

for i in range(0,n-1):
    y = y- list1[i]
    total += list1[i] * y % mod

total = total % mod
print(total)
N = int(input())
A = list(map(int, input().split()))
ans = 0
S = sum(A) - A[0]
for i in range(0, N-1):
  ans = (ans + A[i] * S) % (10**9+7)
  S -= A[i+1]
print(ans)
def s():return int(input())
def mp():return map(int,input().split())
a = s()
b = list(mp())
ans=0
t = sum(b)%(10**9+7)
for i in range(a):
	t-=b[i]
	ans+=b[i]*t
	ans%=(10**9+7)
print(ans)
N = int(input())
int_list = list(map(int, input().split()))

sum_num = 0
sum_temp = sum(int_list[1:])

for i in range(N-1):
  sum_num += int_list[i] * sum_temp
  sum_temp -= int_list[i+1]
    
print(sum_num % (10 ** 9 + 7))
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    square = []
    for i in A:
        square.append(i**2)
    return (sum(A)**2 - sum(square))//2 % (10**9+7)


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

s = sum(a)
t = sum(map(lambda x:x**2,a))
ans = ((s**2 - t)//2) % (10**9 + 7)
print(ans)
n = int(input())
arr = [int(a) for a in input().split()]

summ = sum(arr)
ans = 0
for i in range(n-1):
    a = arr[i]
    summ -= arr[i]
    b = summ
    ans += (a*b)%(int(1e9+7))

print(ans%(int(1e9+7)))
N = int(input())
A = list(map(int, input().split()))

mod = int(1e+9 + 7)

rui = 0
for i in range(N):
    rui = (rui + A[i])%mod
    
answer = 0
for i in range(N-1):
    rui = (rui - A[i])%mod
    answer = (answer + rui * A[i])%mod
    
print(answer)
n = int(input())
a = list(map(int, input().split()))

MOD = pow(10, 9) + 7

two_inv = pow(2, -1, MOD)

sq = []

for x in a:
    sq.append(x ** 2 % MOD)

s = sum(a) % MOD
s_sq = sum(sq) % MOD

print((pow(s, 2, MOD) - s_sq) * two_inv % MOD)
N=int(input())
A=list(map(int,input().split()))
A.reverse()
ans=0
tempsum=0
for i in range(len(A)-1):
    tempsum+=A[i]
    ans=ans+tempsum*A[i+1]

print(ans%(10**9+7))
n = int(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)
N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
S = sum(A)

ans = 0
for i in range(N-1):
    S -= A[i]
    ans += (A[i] * S) % MOD
print(ans%MOD)
N = int(input())
A = list(map(int, input().split()))

sumA = sum(A)

ans = 0

for i in range(len(A)):
    sumA -= A[i]
    ans += sumA * A[i]

print(ans % 1000000007)
n = int(input())
mod = 1000000007
a = [int(i)%mod for i in input().split()]
s = [0]*(n+1)
for i in range(n)[::-1]:
    s[i] = (s[i+1] + a[i])%mod
ans = 0
for i in range(n-1):
    ans += s[i+1]*a[i]%mod
    ans %= mod
print(ans)
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
total = 0
sum_sqr = 0
sqr_sum = 0
for i in range(n):
    sum_sqr = (sum_sqr + a[i])
sum_sqr = (sum_sqr * sum_sqr)
for i in range(n):
    sqr_sum = (sqr_sum + ((a[i] * a[i])))
# print(sqr_sum, sum_sqr)
total = (sum_sqr - sqr_sum) // 2
print(total%mod)
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N = int(input())
A = list(map(int,input().split()))
a1 = sum(A)%p
B = [A[i]**2 for i in range(N)]
a2 = 0
for i in range(N):
    a2 = (a2+B[i])%p
ans = (((a1*a1)%p-a2)%p * pow(2,p-2))%p
print(ans)
mod=10**9 + 7
n=int(input())
a=list(map(int,input().split()))
ans=0
total=sum(a)
for i in a:
  total -= i
  ans += total*i
print(ans%mod)
#!/usr/bin/env python

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

mod = int(1e9)+7

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

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

S = sum(a)
S2 = 0

for i in a:
    S2 += i * i

print((S*S - S2)//2 % inf)
import copy

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

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])%mod)
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%mod) %mod
print(int(res))
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 = 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()
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
rs = [0]
for i in range(n):
    rs.append(rs[-1] + a[n - 1 - i])

ans = 0
for i in range(n - 1):
    ans += a[i] * rs[n - 1 - i] % MOD
print(ans % MOD)
n = int(input())
arr = list(map(int,input().split()))
result = 0
sum = arr[0]
for i in range(1,len(arr)):
    result += (sum*arr[i])
    sum+=arr[i]
print(result%1000000007)
import copy
n = int(input())
a = list(map(int,input().split()))
a_2 = copy.copy(a)
a_2.reverse()
sinu = [0] * n
t = 0
for i in range(n):
    t += a_2[i]
    sinu[i] += t
sinu.reverse()

ans = 0
for i in range(n-1):
    #print(a[i],sinu[i+1])
    ans += a[i] * sinu[i+1]

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

def main():
  n = int(input())
  a = list(map(int, input().split()))
  wa = sum(a)%mod
  ans = 0
  for i in range(n):
    wa -= a[i]%mod
    ans += (a[i]*wa)
    ans %= mod
  print(ans)
  
if __name__ == "__main__":
  main()
n=int(input())
a=list(map(int,input().split()))
mod=1000000007
sum=0
tmp=0
o=0
while(o<n):
    tmp = (a[o]%mod + tmp%mod)%mod
    o += 1

for i in range(n):
    tmp=(tmp%mod-a[i]%mod)%mod
    sum=((a[i]%mod)*tmp)%mod+sum%mod



print(sum%mod)
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n): 
    s = s + a[i] 

e = s * s 

ss = 0
for i in range(n): 
    ss += a[i] * a[i] 
p =  (e - ss) // 2
print(p % (10**9 + 7))
MOD = 10 ** 9 + 7

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

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

area = sum(l) * sum(l)

for i in l:
    area -= i*i

ans = area//2
ans = ans % mod
print(ans)
I=lambda:list(map(int,input().split()))
mod=10**9+7
n,=I()
l=I()
pre=l.copy()
suf=l.copy()
for i in range(n-2,-1,-1):
	suf[i]+=suf[i+1]
ans=0
#print(suf)
for i in range(n-1):
	ans+=(l[i]*suf[i+1])
	ans%=mod
print(ans)
# -*- coding: utf-8 -*-

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

s = 0
summation = 0
for i in a_list:
  s += i

for i in a_list:
  s -= i
  summation += i * (s)

print(summation % (10 ** 9 + 7))
n = int(input())
li = list(map(int, input().split()))
res = 0
sum1 = sum(li)
sum2 = 0
m = 10**9 + 7
for i in range(0, len(li)-1):
    sum2 += li[i]
    res = (res + li[i]*(sum1-sum2))%m
print(res)
n = int(input())
A = [*map(int, input().split())]
s = sum(A)
s *= s
for a in A: s -= a * a
s //= 2
print(s % (10**9 + 7))
n = int(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 += a[i]*s % mod
  ans = ans % mod

print(ans % mod)
n=int(input())
a=list(map(int,input().split()))

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

MOD = 10**9+7
result = 0
for i in range(n):
  result += a[i]*(s[n] - s[i+1])%MOD
print(result%MOD)
n = int(input())
a = [int(i) for i in input().split()]
s = [0 for i in range(n)]

s[-2] = a[n-1]
for i in range(3, n+1):
  s[-i] = s[-(i-1)] + a[-(i-1)]
  
ans = 0
for i in range(n):
  ans += a[i] * s[i]
  
print(ans % ((10**9)+7))
N=int(input())

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

mod=10**9+7
summy=[]
a=0
for i in range(N):
    a += A[i]
    a %= mod
    summy.append(a)

ans=0
for i in range(N-1):
    ans += summy[N-2-i]*A[N-1-i]
    ans %= mod
print(ans)
from itertools import accumulate


def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    ac = list(accumulate(a))
    ans = 0
    for i in range(n):
        ans += a[i] * (ac[-1] - ac[i])
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()
def main():
    input()  # n
    array = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7
    total = 0
    center_blocks = 0
    for x in array:
        total += x
        center_blocks += x ** 2
    total = total ** 2
    return (total - center_blocks) // 2 % mod


if __name__ == '__main__':
    print(main())
n = int(input())
*arr, = map(int, input().split())
modulo = 10 ** 9 + 7
p = arr.copy()
p.append(0)
for i in range(len(p) - 2, -1, -1):
    p[i] = (p[i] + p[i + 1]) % modulo

ans = 0
for i in range(n):
    ans += arr[i] * p[i + 1]
    ans %= modulo
print(ans)
N = int(input())
A = list(map(int,input().split()))
a = 0
s = 0
for i in range(N):
    a = (a+A[i])%(10**9+7)
for i in range(N-1):
    a = a-A[i]
    s = (s+A[i]*a)%(10**9+7)
print(s)
N =int(input())
A = list(map(int,input().split()))
suma = sum(A)
Ans = 0
for a in A:
    suma -= a
    Ans += suma*a
    Ans = Ans % (10**9+7)
print(Ans)
n = int(input())
a = list(map(int, input().split()))
A = sum(a)
s = 0
for i in range(n-1):
    A = A - a[i]
    b = (a[i]*A)%(10**9+7)
    s = s + b
print(s%(10**9+7))
N = int(input())
As = list(map(int, input().split()))

sum = 0
for i in range(N):
    sum += As[i]
    sum %= 10**9+7

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

print(ans)
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations, accumulate
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    cA = list(accumulate(A))
    ans = 0
    for i in range(N - 1):
        term = A[i] * (cA[-1] - cA[i]) % MOD
        ans = (ans + term) % MOD
    print(ans)

if __name__ == '__main__':
    main()
s = int(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)
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


MOD = 10**9 + 7


def main():
    n = _i()
    a = list(_ia())
    s = [0] * n
    for i in range(n-2, -1, -1):
        s[i] = s[i+1] + a[i+1]

    ans = 0
    for ai, si in zip(a, s):
        ans = (ans + (ai * si)) % MOD
    return ans


if __name__ == "__main__":
    print(main())
N = int(input())
A = list(map(int,input().split()))
p = 0
c = len(A) - 1
total = 0
while 0 < c:
    p += A[c]
    total = total + p * A[c-1]
    if total >= 1000000007:
        total %= 1000000007
    c -= 1

print(total)
n = int(input())
numbers = list(map(int, input().split()))
result = 0
sum_of_numbers = sum(numbers)
for i in range(n - 1):
    sum_of_numbers -= numbers[i]
    result += numbers[i] * sum_of_numbers
    result %= 1000000007
print(result)
n = int(input())
a = list(map(int, input().split()))

length = len(a)
total = sum(a)

ans = 0
for i in range(0,length):
    total -= a[i]
    ans += (a[i] * total)


print(ans % (10**9 + 7))
#import 
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
mod = 10 ** 9 + 7

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

s = 0
for i in range(n-1):
    sum -= a[i]
    s = (s + a[i] * sum) % mod
print(s)
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
ans=0
sums=sum(arr)
for val in arr:
    ans+=(val*sums)%mod
    ans-=(val*val)%mod
print((ans*pow(2,mod-2,mod))%mod)
MOD = 10**9 + 7
def solve(n, a):
    t = sum(a)
    return sum((t-x)*x for x in a) // 2 % MOD

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

from itertools import combinations

num = 10**9 + 7
ans = 0

B = []
b = 0
for i in reversed(A[1:]):
    b += i
    B.append(b)
B.reverse()
for x, y in zip(A[:-1], B):
    ans += x*y
    ans %= num
print(ans)
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
ruiseki = [A[i] for i in range(N)]

for i in range(1,N):
    ruiseki[i]=ruiseki[i]+ruiseki[i-1]

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

print(ans)
n=int(input())
a=list(map(int,input().split()))
mod=pow(10,9)+7
sa=[0]
tmp=0
for x in a:
  tmp+=x
  sa.append(tmp)
ans=0
for i in range(n-1):
  ans+=a[i]*(sa[n]-sa[i+1])
  ans%=mod
print(ans)
def resolve():
    n = int(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()
N = int(input())
a = list(map(int,input().split()))
a_s = sum(a)
mod = 10**9+7
s = 0
for i in range(N-1):
    b = a[i]
    a_s -= b
    s += b*(a_s)
    s %= mod
print(s)
n = int(input())
A = list(map(int,input().split()))
total = sum(A)
ans = 0
for i in range(n):
    total -= A[i]
    ans += A[i]*(total)
print(ans%(10**9 + 7))
import numpy as np
def main():
    MOD = 10**9 + 7
    N = int(input())
    A = np.array(list(map(int, input().split())), dtype="i4")

    A = A % MOD
    rsumA = np.cumsum(A[::-1]) % MOD
    count = 0
    for i in range(len(A)-1):
        a = A[i]
        other = rsumA[len(A) - i - 2]
        count += (a * other) % MOD
    count %= MOD
    print(count)





if __name__ == '__main__':
    main()
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
X = (A - B) % 1000000007

print((X * int((1000000007 + 1)/2)) % 1000000007)
# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
S = sum(A)%mod
ans = 0
for k in range(N-1):
  S -= A[k]
  S %= mod
  ans += S*A[k]
  ans %= mod
print(ans)
import sys
input = sys.stdin.readline

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

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

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


print(answer % (10**9 + 7))
N = int(input())
A = list(map(int, input().split()))
base = 10 ** 9 + 7
X = 0
Y = 0
for i in A:
  X += i * i
  Y += i
  X %= base
  Y %= base
Y = (Y * Y) % base
ans_ = ( Y - X ) % base

m = pow(2, base-2, base)
#print(m)
print( (ans_ * m) % base )
n=int(input())
alist=list(map(int,input().split()))
MOD=10**9+7
nijo=0
for i in range(n):
    nijo+=(alist[i]**2)
gokei=sum(alist)

ans=(gokei**2-nijo)
ans=ans//2
ans=ans%MOD
print(ans)
N = int(input())
A = list(map(int,input().split()))
total = sum(A)
ans = 0
for i in A:
    total-=i
    ans+=total*i
    ans%=(10**9+7)
print(ans)
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
acc = [0]
ans = 0
for i in a:
    acc.append(acc[-1]+i)
acc = acc[1:]
for i, v in enumerate(a):
    ans += (v*(acc[-1]-acc[i]))%MOD
print(ans%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)
#sum2 = (A**2).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())
a = list(map(int, input().split()))

su = sum(a)
sus = 0

for i in a:
    su = su - i
    sus = sus + i * su

print(sus % (10**9 + 7))
import sys
input = sys.stdin.buffer.readline
from itertools import accumulate

MOD = 10**9 + 7

N = int(input())
A = [0] + list(map(int, input().split()))
C = list(accumulate(A))

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

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

inv_A=A[::-1]

b = [0]*N
b[0]=inv_A[0]
for i in range(1,N):
    b[i] = (b[i-1]+inv_A[i])%mod
inv_b = b[::-1]

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

MOD = 10**9+7

t = sum(A)**2
d = sum(a*a for a in A)
print(((t-d)//2)%MOD)
n = int(input())
mod = 10**9+ 7
a = list(map(int,input().split()))
ans = (sum(a)%mod)**2 - sum([x**2%mod for x in a])
ans *= 5*10**8+4
ans %= mod
print(ans)
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
s = [0]*n
s[-1] = a[-1]
for i in range(n-2,-1,-1):
    s[i] = (s[i+1]+a[i])%mod
for i in range(n-1):
    ans = (ans + (a[i]*s[i+1]))%mod
print(ans)
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    prefix = [a[0]]
    for i in range(1,n):
        prefix.append(prefix[i-1] + a[i])
    ans = 0
    for i in range(n-1):
        d = (a[i]*(prefix[-1] - prefix[i]))%mod
        ans = ans + d
        ans = ans%mod
    print(ans)
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

s = sum(A)
key = 0
for i in range(N):
    s -= A[i]
    key += s*A[i]
print(key % mod)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    ans += a[i]*aa
ans %= mod
print(ans)
N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
S = sum(A)
S2 = sum(map(lambda x: x*x,A))
ans = (S*S - S2)// 2 % mod
print(ans)
n = int(input())
an = [int(num)  for num in input().split()]

an_total = sum(an)
answer = 0
for i in range(len(an)-1):
  an_total -= an[i]
  answer +=  an[i] * an_total
print(answer%1000000007)
n = int(input())
L = [int(i) for i in input().split()]

sq = 0
for i in range(n):
  sq += L[i]**2

tmp = (pow(sum(L),2) - sq) // 2
print(tmp % (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()))

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

y = (z ** 2) % 2000000014

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

w = int(((y - x) / 2) % 1000000007)
print(w)
N = int(input())
Alst = list(map(int, input().split()))
l = len(Alst)
Blst = [0]*l
k = 0
ans = 0
for i in range(l-1, 0, -1):
    k = (k + Alst[i])%(10**9 + 7)
    Blst[i] = k

for j in range(l-1):
    ans = (ans + Alst[j] * Blst[j+1])%(10**9 + 7)

print(ans)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
s1 = 0
s2 = 0
M = 10**9+7
for item in a:
    s1 += item
    s2 += item**2
    s1 %= M
    s2 %= M
ans = (s1**2 - s2)*pow(2, M-2, M)
print(ans%M)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
array_sum = sum(a) % mod
ans = 0
for i in range(n):
    ans += a[i] * array_sum % mod
    ans -= a[i] * a[i] % mod
print((ans * pow(2,-1,mod)) % mod)
n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
s = 0
ans = 0
for a in A:
    ans += s*a
    ans %= mod
    s += a
    s %= mod
print(ans)
n = int(input())
A = list(map(int, input().split()))

S = sum(A)
S2 = sum(map(lambda x: x * x, A))

print((S*S-S2)//2 % 1000000007)
n = int(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)
import sys
import itertools
tokens = itertools.chain.from_iterable(map(str.split, sys.stdin))

mod = 1000000007
n = int(next(tokens))
a = [int(next(tokens)) % mod for _ in range(n)]

sms = []
sma = sum(a)
for i in range(n):
    sma -= a[i]
    sms.append(sma)
#print(sms)

m = 0
for i in range(n - 1):
    sm = sms[i]
    #print(i, a[i], sm)
    m = (m + a[i] * sm) % mod

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

res = 0
ruiseki = 0
for j in range(n):
    if j == 0:
        continue
    ruiseki += a[j-1]
    res = res + a[j]*ruiseki
print(res % ((10 **9)+7))
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
for i in range(0,n):
    x = x + a[i]
for i in range(0,n):
    y = y + (a[i]**2)
print(((x**2-y)//2) % (10**9+7))
N = input()
nums = list(map(int, input().split()))
rests = []
rest_sum = 0
for i in reversed(nums):
    rest_sum += i
    rests.append(rest_sum)

sum_num = 0
for i in range(len(nums)-1):
    sum_num += nums[i]*rests[-(i+2)]
    if sum_num > 10**9 + 7:
        sum_num = sum_num % (10**9 + 7)
    

print(sum_num)