peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
sum_a = sum(a)
result = 0
for i in range(n):
  result += a[i] * (sum_a - a[i])
print((result)//2 %(10**9+7))
N=int(input())
A=list(map(int, input().split()))
MOD=1000000007
s=0
for i in range(1,N):
    s+=A[i]
    s%=MOD

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

ans = sum(al)**2
for a in al:
    ans -= a**2

mod = 10**9+7
print((ans//2)%mod)
mod = 10**9 + 7
n=int(input())
s=list(map(int,input().split()))
s2=sum(map(lambda x: x ** 2,s))
ans=(((sum(s))**2)-(s2))//2%mod
print(ans)
n = int(input())
A = list(map(int, input().split()))

sum_A = sum(A)

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

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

print(ans % m)
N = int(input())
A = [int(a) for a in input().split()]

mod = 10**9 + 7

print(((sum(A)**2 - sum([i**2 for i in A]))//2) % mod)
n = int(input())
a = list(map(int, input().split()))

answer = 0
mod = 10**9 + 7
total_sum = sum(a)
for idx in range(n - 1):
    total_sum -= a[idx]
    answer += a[idx] * total_sum

print(answer % mod)
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 = (ans + S*A[i])%MOD
    
print(ans)
n = int(input())
a = list(map(int, input().split()))

all_sum = (sum(a) ** 2)
diff = [(a[i] ** 2) for i in range(n)]

ans = (all_sum - sum(diff)) // 2

print(ans % (10 ** 9 + 7))
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
S = 0
_sum = 0
for i in range(N):
    S += A[i]
    S %= mod
for i in range(N):
    S -= A[i]
    if S<0:
        S += mod
    _sum += A[i]*S
    _sum %= mod

print(_sum)
nn = int(input())
aa = list(map(int, input().split()))
bb = [0]*(nn-1)
mysum = sum(aa)
mydiff = 0

for i in range(1,nn):
    mydiff += aa[i - 1]
    bb[i-1] = mysum - mydiff

finalsum = 0
for i in range(nn-1):
        finalsum += aa[i]*bb[i]
        finalsum = finalsum % (10**9 + 7)

print(finalsum)
D = 10 ** 9 + 7
N = int(input())
L= list(map(int, input().split()))

ans = L[0] * L[1] % D
sub = L[0] + L[1]
for n in range(2,N):
    ans += L[n] * sub
    sub += L[n]
    
print(ans % D)
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
res=0
for i in range(N-1):
    s-=A[i]
    res+=A[i]*s
print(res%(10**9+7))
n = int(input())
an = list(map(int,input().split()))

mod = 10**9 + 7
total =sum(an)
ans = 0
z = an[0]

for x in range(n-1):
  nokori = total-z
  ans += an[x] * nokori % mod
  z += an[x+1]

    
ans = ans % 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 * a[i]

x = k//2
t = 10 ** 9 + 7
ans = x % t
print(ans)
#C
N = int(input())
A = list(map(int, input().split()))
result = sum(A)**2
for i in A:
    result -= i**2
print((result//2)%1000000007)
n=int(input())
arr=list(map(int,input().split()))
s=sum(arr)
ans=0
m=10**9+7
c=0
for i in arr:
    c+=i
    ans+=i*(s-c)
    ans%=m
print(ans)
N = map(int, input())
An = list(map(int, input().split()))
mnum = 10 ** 9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
    answer = (answer + CumSum * An[i]) 
    CumSum = (CumSum + An[i])
print(answer%mnum)
n = int(input())
arr = [int(x) for x in input().split()]
arr.insert(0,0)
prefix = [0 for x in range(n+1)]
for i in range(1,n+1):
    prefix[i] = prefix[i-1]+arr[i];

ans = 0
mod = int(1e9+7)
for i in range(1,n):
    ans += arr[i]*(prefix[n]-prefix[i])
print(ans%mod)
n = int(input())
a = list(map(int, input().split()))
t = 0
r = 0
mod = 10**9+7
for i in range(n-1, 0, -1):
    r += a[i]
    t += a[i-1]*r
print(t%mod)
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
  if ans>(10**9+7):
    ans=ans%(10**9+7)
print(ans)
import sys
def input():
    return sys.stdin.readline()[:-1]


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

    
if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007
sum = 0
for i in range(N):
    sum = sum + A[i]

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

print(res % MOD)
N = int(input())
A = list(map(int,input().split()))

B = [0]
b = 0

mod = 10**9 + 7

for i in range(N):
    b+=A[i]
    b%=mod
    B.append(b)

ans = 0

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

print(ans)
n=int(input())
c = list(map(int, input().rstrip().split()))
ans=0
b=10**9+7
sum1=0
for i in range(n):
    ans=(ans+c[i]*sum1)%b
    sum1=(sum1+c[i])%b

    
    
    
        
print(ans)
from collections import deque
N = int(input())
A = list(map(int, input().split()))
#N=3
#A=[1,2,3]
q=deque(A)
#print(q)
ans=0
sums=sum(q)
#print(sums)
for i in range(N-1):
    qwe=q.popleft()
    ans+=qwe *(sums-qwe)
    sums-=qwe
print(ans%(10**9+7))
N = int(input())
A = [int(v) for v in input().split()]
MOD = int(1e9 + 7)

S = sum(A)
SQ = S * S
IS = sum(a*a for a in A)

print(((SQ - IS) // 2) % MOD)
N = int(input())
A = list(map(int, input().split()))

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

for i in range(N-1):
  sum = sum - A[i]
  M += A[i] * sum
  if M > 10 ** 9 + 7:
    M = M % (10 ** 9 + 7)
print(M)
n = int(input())
a= list(map(int, input().split()))
s=sum(a)
INF=1000000007
ans=0

for i in range(n-1):
    s-=a[i]
    ans+=a[i]*s
    ans%=INF
print(ans)
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()

MOD = 10 ** 9 + 7


def modinv(x):
    return pow(x, MOD - 2, MOD)


def main():
    s = sum(A) % MOD
    ans = s * s % MOD
    for a in A:
        ans = (ans - a ** 2) % MOD
    ans = ans * modinv(2) % MOD
    print(ans)


if __name__ == "__main__":
    main()
import numpy as np
N = int(input())
A = list(map(int ,input().split()))
sum=0
ans=0
for i in range (0,N-1):
  sum=sum+A[i]
  sum=sum%(1000000000+7)
  ans=ans+sum*A[i+1]
  ans=ans%(1000000000+7)
print(ans)
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
su=0
for i in range(n):
	s=s-l[i]
	s=s%1000000007
	su=su+(l[i]*s)
	su=su%1000000007
print(su)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    K = int(1e9)+7
    acum = [0]
    for i  in range(N):
        acum.append(acum[i]+A[i])
    ans = 0
    for i in range(N):
        ans += A[i]*(acum[N]-acum[i+1])
        ans %= K
    print(ans)
if __name__ == '__main__':
    main()
N = int(input())

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

MOD = 1000000007
s = sum(A)

ans = 0

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

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

max = (10 ** 9) + 7

#入力配列の総和
line = 0
for i in range (n):
    line += a[i]

#a11, a22, ...対角線要素の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((line*line) - rem) // 2

ans = sum % max

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

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

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

for i in range(N-1):
    ans += A[i] * (sumA-B[i]) % mod
    ans = ans%mod
    
print(ans)
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()
mod = 10 ** 9 + 7

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

s = sum(a) 

ans = 0

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

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

mod = 10**9 + 7

s = sum(A)
ans = 0
for i, a in enumerate(A):
    s -= a
    ans = (ans + s * a) % mod

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

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

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

ans %= MOD

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

ans = 0
s = 0

def mod(x):
    return int(x % int(1e+9 + 7))

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

    ans = mod(ans) 

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

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

print (ans)
N = int(input())
MOD = 10**9 + 7
A_s = list(map(int, input().split()))
ruiseki = [] 
for i, A in enumerate(A_s):
    if i == 0:
        ruiseki.append(A)
        continue
    ruiseki.append(ruiseki[i-1]+A)
answer = 0
for i, r in enumerate(ruiseki):
    answer += (A_s[i] * (ruiseki[N-1]-ruiseki[i]))
    answer %= MOD
print(answer)
import sys
input = sys.stdin.readline

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

B = [A[0]]
for i in range(1, n):
    B.append((B[-1] + A[i]) % mod)

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

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

ans = 0
for i in range(n):
  array_sum -= a[i]
  ans += array_sum * a[i]
  ans %= MOD
  
print(ans)
import itertools

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

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

p = int(1e9 + 7)

result = 0
total = 0
for i in range(N - 1, 0, -1):
    total = (total + A[i]) % p
    result = (result + A[i-1] * total) % p
print(result)
N = int(input())
A = map(int,input().split())
ans = 0
ans2 = 0
mod = 10 ** 9 + 7
for a in A:
    ans += a
    ans2 += a**2

print(((ans **2 - ans2)//2)%mod)
n = int(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)
import sys
input = lambda : sys.stdin.readline().rstrip()

M = (10**9)+7
n = int(input())
As = map(int, input().split(" "))

cumsum = []
cur = 0
out = 0
for i in range(n-1):
    cur += As[i]
    out += cur*As[i+1] 
    out = out % M
print(out)
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] + list(accumulate(A))
    MOD = 10 ** 9 + 7
    ans = 0
    for i in range(N):
        ans += A[i] * (B[N] - B[i+1])
        ans %= MOD

    print(ans)




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

mod = 10 ** 9 + 7

summ = 0
quadsum = 0

for k in range(n):
    summ = (summ + A[k]) % mod
    quadsum = (quadsum + A[k]*A[k])%mod

ans = (summ*summ)%mod - quadsum
if ans % 2 == 1:
    ans += mod
ans = (ans/2)%mod
print(int(ans))
n = int(input())
arr = list(map(int,input().split()))
ans = 0
tmp = 0

for i in range(n-1):
    tmp += arr[i]%1000000007
    ans += tmp*arr[i+1] % 1000000007

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

N=int(input())
A=list(map(int,input().split()))
B=[0]
for x in A:
  B.append(B[-1]+x)

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

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

mod = 1000000007


ans = 0
n = A[0]
for a in A[1:]:
    ans += a * n
    n += a

print(ans%mod)
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
import numpy as np

nmod = 1000000007

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

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

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

def twosekisum(A):
    return (sum(A)**2-sum([i**2 for i in A]))//2
print(twosekisum(A)%(10**9+7))
N = int(input())
A = list(map(int,input().split()))

Sum = sum(A)
ans = 0
for i in range(N):
  Sum = Sum-A[i]
  AA = Sum*A[i]
  ans += AA
  ans = ans%(10**9 + 7)
print(ans)
MOD = 1000000007
n = int(input())
a = [int(_) for _ in input().split()]
p = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    p[i] = p[i + 1] + a[i]
ans = 0
for i in range(n):
    add = a[i] * (p[i] - a[i])
    add = add % MOD
    ans += add
    ans = ans % MOD
print(ans)
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):
    sum_a=sum_a-A[i]
    ans+=sum_a*A[i]
    ans%=mod

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

sumA = sum(A)
sumB = 0
sumC = sumA

for i in range(n):
    sumC = sumC- A[i]
    sumB += A[i] * sumC

print(sumB % (10**9 + 7))
n = int(input())
x = list(map(int, input().strip().split()))
sum=0
minsum=0
for i in range(0,n):
    minsum += x[i]
for i in range(0,n-1):
    minsum-=x[i]
    sum += x[i]*minsum
    if(sum>10**9+7):
        sum%=(10**9+7)
print(sum)
N = int(input())
A = list(map(int, input().split()))

MOD = 1000000007

a = 0
b = 0
for i in range(N):
    a += A[i] % MOD
    b += (A[i] ** 2) % MOD
a = a ** 2
ans = (a - b) * pow(2, MOD - 2, MOD) % MOD
print(ans)
n = int(input())
a = list(map(int, input().split()))

MOD = 10 ** 9 + 7

sum = sum(a) % MOD
ans = 0

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

print(ans)
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    
    temp = 0
    a_sum = []

    for i in range(len(a)):
        temp += a[i]
        a_sum.append(temp)

    total = 0
    a_sum.reverse()
    a.reverse()

    for i in range(1, len(a_sum)):
        total += a[i-1]*a_sum[i]
    
    print(total % (10**9+7))

if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
ans=0
wa=sum(a)
for i in range(n):
  wa-=a[i]
  ans=(ans+(wa*a[i]))%(10**9+7)
print(ans)
N = int(input())
A = list(map(int, input().split()))

prefix = [0]
for a in A:
    prefix.append(prefix[-1] + a)

res = 0
M = 10 ** 9 + 7
for i, a in enumerate(A[:-1], start=1):
    res += a * (prefix[N] - prefix[i])
    res %= M
print(res)
n = int(input())
a = list(map(int,input().split()))
sum_a = sum(a)
ans = 0

for i in a:
    sum_a -= i
    ans += i * sum_a
    ans %= 10**9 + 7
    
print(ans)
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
S = sum(A) % MOD
ans = (S ** 2) % MOD
for a in A:
    ans -= a**2
    ans %= MOD

ans *= pow(2, MOD-2, MOD)
ans %= MOD
print(ans)
################ C
n = int(input())
nums = list(map(int, input().split()))

total = 0
total_sum = sum(nums)
for num in nums:
    total_sum -= num 
    total += num * total_sum
    
print(total % 1000000007)
def resolve():
    N = int(input())
    A = [int(i) for i in input().split(maxsplit=N)]
    presum = [0 for _ in range(N + 1)]
    for i in range(N):
        presum[i + 1] = presum[i] + A[i]
    sumA = 0
    for i in range(1, N):
        sumA += (A[i] * (presum[i])) % (10**9 + 7)
    print(sumA % (10**9 + 7))


resolve()
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
mo = 10 ** 9 + 7
for i in range(n):
    ans += s * a[i]
    s += a[i]
print(ans % mo)
def solve():
    N = int(input())
    A = list(map(int, input().split()))

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

  #  print(sum_a)

    ans = sum_a % 1000000007

    print(ans)


if __name__ == "__main__":
    solve()
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    are=10**9+7
    s=sum(a)
    ans=0
    for i in range(n):
        s-=a[i]
        ans+=a[i]*s
        ans=ans%are
    print(ans)
resolve()
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 = input()
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(res)
# C - Sum of product of pairs
from itertools import accumulate


def main():
    N, *A = map(int, open(0).read().split())
    rev_cumsum = list(accumulate(reversed(A[1:])))[::-1]
    MOD = 10 ** 9 + 7
    res = sum(a * c for a, c in zip(A[:-1], rev_cumsum)) % MOD
    print(res)


if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
sum_a = 0
for a in A:
    a = a % mod
    sum_a = (sum_a + a) % mod
ans = 0
for a in A:
    sum_a = (sum_a - a) % mod
    ans += (a % mod) * sum_a
    ans = ans % mod
print(ans % mod)
N = int(input())
A = [int(s) for s in input().split()]
mod = 10**9+7

wa = 0
wa_list = []
for i in range(N)[::-1]:
    if i == 0:
        break
    wa += A[i]
    wa_list.append(wa)

wa_list.reverse()
ans  = 0
for i in range(N-1):
    seki = A[i]*wa_list[i]
    ans += seki

print(ans % mod)
import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    totalSum = sum(arr) % MOD
    currSum = 0

    for num in arr:
        currSum += num
        ans = (ans + num * (totalSum - currSum)) % MOD

    return ans % MOD


N = readInt()
arr = readList()

print(solve(N, arr))
import numpy
N = int(input())
A = list(map(int, input().split()))

res = []
res.append(A[0])
for i in range(len(A)-1):
    res.append(res[i] + A[i+1])

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

print(sum % (10**9+7))
n = int(input())
li_a = list(map(int, input().split()))
answer = 0
su = sum(li_a)
mo = (10 ** 9) + 7
for idx, a in enumerate(li_a):
    su = su - a
    answer += (a * su)
print(answer % mo)
n=int(input())
a=list(map(int, input("").split()))
o=0
aa=[]
for i in a:
    aa.append(i**2)
s=sum(a)
o=(s**2-sum(aa))//2
o%=10**9+7
print(o)
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
S = sum(A)**2
SS = 0

for i in range(N):
    SS += A[i]**2

print(((S - SS)//2)%mod)
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)
N=int(input());
X=list(map(int,input().split()))
s=0;t=0;
for i in range(N):
  s+=X[i];
  t+=X[i]*X[i];
print(((s*s-t)//2)%1000000007)
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)**2
mod = 10**9 + 7

for i in range(n):
    ans -= a[i]**2
ans //= 2
print(ans%mod)
N,*A = map(int, open(0).read().split())
s = 0
m = 1000000007
for x in A:
    s = (s+x) % m
ans = 0
for x in A:
    s = (s-x) % m
    ans = (ans+x*s) % m
print(ans)
import numpy as np
n = int(input())
lst = list(map(int,input().split()))
s = 0
t = 0
for x in lst:
  s += x
  t += (x ** 2) % (10**9+7)

w = (s**2-t) % (10**9+7)
if w % 2 == 0:
  print(w//2)
else:
  print((w+10**9+7)//2)
N = int(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))
import sys
readline = sys.stdin.readline

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

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

mod=10**9+7
import numpy as np

cum=[]

prev=0
for i in range(n):
    tmp = prev%mod +a[i]%mod
    cum.append(tmp)
    prev = cum[-1]


ans=0
for i in range(n-1):
    p=a[i]
    t = cum[-1] - cum[i]

    ans+=(p*t)%mod

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


mod = int(1e9 + 7)


def fexp(x, y):
    ret = 1
    while y > 0:
        if y % 2 == 1:
            ret = ret * x % mod
        x = x * x % mod
        y = y // 2
    return ret


input()
a = list(read_ints())
s = sum(a)
ans = 0
for i in a:
    ans = (ans + i * (s - i)) % mod
print(ans * fexp(2, mod - 2) % mod)
n=int(input())
list=input().split()
sum=0
for i in range(n):
 sum+=int(list[i])
sum=sum*sum
sum2=0
for i in range(n):
 sum2+=int(list[i])*int(list[i])
sum-=sum2
sum//=2
sum%=1000000007
print(int(sum))
N = int(input())
A = list(map(int, input().split()))
mod = int(1e9) + 7
R = [0 for _ in range(N+1)]
for i in range(N):
  R[i+1] = R[i] + A[i]
S = 0
for i in range(N-1):
  S += A[i] * (R[N] - R[i+1]) % mod
  S %= mod
print(S)
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

MOD = 10**9+7
i2 = (MOD+1)//2


r = sum(a)
r *= r
r -= sum(i*i for i in a)

r *= i2
print(r%MOD)
n=int(input())
l=list(map(int,input().split()))
b=sum(l)**2
a=0
for i in range(n):
    a+=l[i]**2
print((b-a)//2%(10**9+7))
n = int(input())
a = list(map(int, input().split()))
b = sum(a)
ans = 0
for i in range(n-1):
    ans += a[i] *(b-a[i])
    b = b - a[i]
print(ans % (10**9 + 7))
MOD = 10 ** 9 + 7

n = int(input())
a = [int(x) for x in input().split()]

sum = 0
for x in a:
    sum += x
    sum %= MOD

ans = 0
for i in range(n):
    sum -= a[i]
    if sum < 0:
        sum += MOD
    ans += a[i] * sum
    ans %= MOD

print(ans)
N=int(input())
A=list(map(int,input().split()))
Mod=10**9+7
two_inverse=pow(2,Mod-2,Mod)

X=sum(A)%Mod

Y=0
for a in A:
    Y+=a*a
    Y%=Mod

print(((X*X-Y)*two_inverse)%Mod)
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=pow(sum(l)%mod,2,mod)
for i in range(n):
    ans-=l[i]**2
    ans%=mod
ans*=pow(2,mod-2,mod)
print(ans%mod)
n=input()
a = list(map(int,input().split()))
suma = sum(a)
r = 0

for i in range(0, len(a) - 1):
  suma -= a[i]
  r += a[i] * suma
print(r % (10 ** 9 + 7))
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
S = [0] # 累積和のリスト
ans = 0
for i in range(N):
    S.append(A[i] + S[i] % mod)
for i in range(N):
    sum = S[N] - S[i + 1]
    if sum < 0:
        sum += mod
    ans += A[i] * sum
print(ans % mod)
n= int(input())
a = list(map(int,input().split()))
allsum= sum(a)
ans = 0
for i in range(n):
    allsum = allsum -a[i]
    ans += a[i]*allsum
o = ans % (10**9+7)
print(o)
n = int(input())
L = list(map(int,input().split()))

L = sorted(L,reverse=True)

#print(L)
t = 0
a = 0
for i in range(1,n):
    t += L[i-1]
    a += (t * L[i]) #% (10**9 + 7)
#    print(t,a)

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

x=sum(a)-a[0]
ans=0

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