CodeEff/ECCO huggingface dataset:
# Original solution
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    MOD = 1000000007

    ans = 0

    for i in range(N-1):
        a = AArray[i]
        asum = sum(AArray[i+1:])
        asum %= MOD
        ans += a*asum % MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArray = LI()
    MOD = 1000000007
    aSum = sum(AArray)
    nowAsum = 0
    ans = 0

    for i in range(N-1):
        a = AArray[i]
        nowAsum += a
        asum = aSum-nowAsum
        asum %= MOD
        ans += a*asum % MOD
    ans %= MOD

    print(ans)


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

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

ans = 0

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

print(ans)


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

ans = 0
sum = sum(A)

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

print(ans)
# Original solution
n = int(eval(input()))
nums = [int(x) for x in input().split()]
total = 0

for i in range(0,n-1):
    total += nums[i]*sum(nums[i+1:n])

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

# Optimized solution
n = int(eval(input()))
nums = [int(x) for x in input().split()]
multinums = [0]
total = 0

for i in range(0,n):  #累積和配列を作成する
    multinums.append(multinums[i]+nums[i])

#print(multinums)

for i in range(0,n):
    #print(nums[i],multinums[n]-multinums[i+1],nums[i] * (multinums[n]-multinums[i+1]))
    total += nums[i] * (multinums[n]-multinums[i+1])

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

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

L = len(A)
total = 0

mod = 10**9+7

for x in range(L):
    tmp = 0
    for y in range(x+1, L):
        tmp += A[y]
    total += tmp*A[x]
print((total % mod))


# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

L = len(A)
total = 0
tmp = 0
mod = 10**9+7
for y in range(L):
    tmp += A[y]

for x in range(L):
    tmp -= A[x] 
    total += tmp*A[x]
print((total % mod))
# Original solution
def main():
	n = int(eval(input()))
	h = list(map(int,input().split()))

	ans = 0

	import itertools

	for i in itertools.combinations(h,2):
		ans += (i[0]%(10**9 + 7)) * (i[1]%(10**9 + 7))
	print((ans%(10**9 + 7)))
	

if __name__ == '__main__':
	main()

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

	sum_h = sum(h)%(10**9 + 7)
	ans = 0
	for i in h:
		i = i%(10**9 + 7)
		sum_h -= i
		ans += i*sum_h

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

	

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

sumA = [A[N-1]]
for i in range(1, N - 1):
    sumA.insert(0, sumA[0]+A[N-i-1])

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

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


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

X = 0
Ans = 0

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

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

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

# Optimized solution
from itertools import accumulate
N = int(eval(input()))
A_list = list(map(int,input().split()))
B_list = A_list[::-1]
C_list = list(accumulate(B_list))
D_list = C_list[::-1]
cnt = 0
for i in range(1,N):
    cnt += (A_list[i-1] * D_list[i]) % (10**9 + 7)

    if cnt >= (10**9 + 7):
        cnt -= (10**9 + 7)
print(cnt)
# Original solution
from sys import stdin
import itertools
def main():
    number = int(eval(input()))
    num_list = list(map(int, stdin.readline().split()))
    comb = list(itertools.combinations(num_list, 2))
    total = sum([c1*c2 for c1, c2 in comb])
    print((total % (1000000007)))
if __name__ == '__main__':
    main()


# Optimized solution
from sys import stdin
import itertools
def main():
    number = int(eval(input()))
    num_list = list(map(int, stdin.readline().split()))
    num_list_sum = sum(num_list)
    total = 0
    for i in range(number):
        num_list_sum -= num_list[i]
        total += num_list[i] * num_list_sum
    print((total % (10**9+7)))
if __name__ == '__main__':
    main()
# Original solution

mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

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


# Optimized solution

mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

for i in range(N):
	add += As[i]
	add %= mod
ans = add * add % mod

for i in range(N):
	ans -= As[i] * As[i] % mod
	if (ans < 0):
		ans += mod

ans *= int((mod + 1) / 2)
ans %= mod

print(ans)
# Original solution
def solve(N, As):
    total = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            total += As[i] * As[j]
    ans = total % (10 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(eval(input()))
    As = list(map(int, input().split()))
    solve(N, As)


# Optimized solution
def solve(N, As):
    Ss = [0]
    total = 0
    for a in As:
        Ss.append(Ss[-1] + a)
    for i in range(N - 1):
        total += As[i] * (Ss[-1] - Ss[i + 1])
    ans = total % (10 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    N = int(eval(input()))
    As = list(map(int, input().split()))
    solve(N, As)
# Original solution
from itertools import accumulate


N, *A = list(map(int, open(0).read().split()))
MOD = 1_000_000_007

acc = list(accumulate(A, initial=0))
ans = 0
for i in range(1, N):
    ans += A[i - 1] * (acc[N] - acc[i])
    ans %= MOD
print(ans)


# Optimized solution
from itertools import accumulate


N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))

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

# Optimized solution
n=int(eval(input()))
aa=list(map(int,input().split()))
su=sum(aa)
new=[n**2 for n in aa]
sa=sum(new)
x=10**9+7
print(((su**2-sa)//2%x))
sa
# Original solution
n=int(eval(input()))
aa=list(map(int,input().split()))
accumulation=[]
total=0

for i in range(n):
    aacut=aa[:(i+1)]
    accumulation.append(sum(aacut))

for i in range(n):
    total+=aa[i]*(accumulation[n-1]-accumulation[i])

x=10**9+7
ans=total%x
print(ans)

# Optimized solution
n=int(eval(input()))
aa=list(map(int,input().split()))
total=0
c=sum(aa)

for i in range(n):
    c-=aa[i]
    total+=aa[i]*c
   
x=10**9+7
ans=total%x
print(ans)
# Original solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

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

# Optimized solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

sums = [0] * N
sums[0] = A[0]
for i in range(N - 1):
    sums[i + 1] = sums[i] + A[i + 1]  # sums[i] stores the sum of A0~Ai

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

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


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

mod = 10 ** 9 + 7
total = 0
for i, a in enumerate(a_list):
    for j in range(len(a_list) - (i + 1)):
        total += (a * a_list[i + 1 + j]) % mod
total = total % mod
ans = total
print(ans)

# Optimized solution
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))

mod = 10 ** 9 + 7
sum_a = sum(a_list)
total = 0
for i, a in enumerate(a_list):
    total += (a * (sum_a - a)) % mod
    sum_a -= a
total = total % mod
ans = total
print(ans)
# Original solution
import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
N = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9 + 7

D = defaultdict(int)
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
# print(D)

ans = 0
for key, item in list(D.items()):
    ans += key * item
    # ans = (ans + (key * item)) % MOD
ans %= MOD
print(ans)


# Optimized solution
import sys
input = sys.stdin.buffer.readline
MOD = 10**9 + 7

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

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

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

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

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

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

total = total % mod
print(total)


# Optimized solution
n = int(eval(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)
# Original solution
import sys
from itertools import combinations

input = sys.stdin.readline

N = int(eval(input()))
A = list(map(int,input().split()))
B = list(combinations(A,2))
sum = 0
for i in range(len(B)):
    sum += B[i][0]*B[i][1]

print((sum%1000000007))



# Optimized solution
import sys
input = sys.stdin.readline

def multipleSum(A, n):
    sum = 0
    for i in range(n):
        for j in range(i + 1, n):
            sum += A[i] * A[j]
    return sum%1000000007

N = int(eval(input()))
A = list(map(int,input().split()))
n = len(A)
print((multipleSum(A,n)))
# Original solution
import sys
input = sys.stdin.readline

def multipleSum(A, n):
    sum = 0
    for i in range(n):
        for j in range(i + 1, n):
            sum += A[i] * A[j]
    return sum%1000000007

N = int(eval(input()))
A = list(map(int,input().split()))
n = len(A)
print((multipleSum(A,n)))

# Optimized solution
import sys
input = sys.stdin.readline

def multipleSum(A, n):
    sum = 0
    for i in range(n):
        sum += A[i]
    mulsum = sum*sum
    insum = 0
    for i in range(n):
        insum+=A[i]*A[i]
    return (mulsum-insum)//2

N = int(eval(input()))
A = list(map(int,input().split()))
n = len(A)
print((multipleSum(A,n)%1000000007))
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

ans = 0

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

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]
S = []
e = 0
for i in A:
    e += i
    S.append(e)
    
ans = 0
for i in range(N-1):
    ans += A[i]%(10**9+7)*((S[N-1] - S[i])%(10**9+7))
    
print((ans%(10**9+7)))
# Original solution
MOD = 1000000007

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

result = 0

for i in range(N):

    for j in range(N-i-1):
        result += n_list[i] * n_list[j+i+1] % MOD
        result = result % MOD

print(result)


# Optimized solution

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

result = 0

s = sum(n_list)
m = 10**9+7

for num in n_list:
    s -= num
    result += num * s % m
    result %= m

print(result)
# Original solution
import sys
n = int(eval(input()))

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

a = [i for i in a if i != 0]

ans = 0
alist = []
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        t = (a[i] * a[j]) % dx
        alist.append(t)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


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

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

S = sum(a)

S2 = sum([x * x for x in a])

ans = (S * S - S2) // 2 % 1000000007
print(ans)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
x=(sum(a))**2
y=0
p=10**9+7
for i in range(n):
    y+=a[i]**2
print(((x-y)//2%p))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
x=0
for i in range(n):
    x+=a[i]**2
y=sum(a)**2
print((((y-x)//2)%(10**9+7)))
# Original solution
N=int(eval(input()))
A=list(map(int, input().split()))
def calc_mod(n):
    return n %(10**9+7)
AA=list(map(calc_mod, A))
X=0
for i in range(N-1):
  X+=AA[i]*sum(AA[i+1:N])
  X=X%(10**9+7)
print(X)

# Optimized solution
N=int(eval(input()))
A=list(map(int, input().split()))
def calc_mod(n):
    return n %(10**9+7)
AA=list(map(calc_mod, A))
X=0
XX=0
for i in range(N-1):
  XX+=AA[N-i-1]
  X+=AA[N-i-2]*XX
  X=X%(10**9+7)
print(X)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
mod = 1000000007
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        add = (A[i]*A[j]) % mod
        sum = sum + add
        sum = sum % mod
print(sum)


# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
mod = 1000000007
sum_A = (sum(A)**2) % mod
B = list([(x**2)% mod for x in A])
sum_B = sum(B) % mod
print((((sum_A-sum_B)*500000004)%mod))
# Original solution
N=int(eval(input()))
l=list(map(int,input().split()))
num=0
ans=0
for i in range(N-1):
  ans+=l[i]*sum(l[i+1:N])%1000000007
print((ans%1000000007))

# Optimized solution
N=int(eval(input()))
l=list(map(int,input().split()))
ans=0
i=0
S=sum(l)
while i<len(l)-1:
  S=S-l[i]
  ans+=l[i]*S
  i+=1
print((ans%1000000007))
# Original solution
n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
mod = 1_000_000_007
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans = (ans+a[i]*a[j]%mod)%mod
print((ans%mod))

# Optimized solution
n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
mod = 1_000_000_007
ans = 0
tmp = 0
for i in range(n-1,0,-1):
    tmp = (tmp+a[i])%mod
    ans += (tmp*a[i-1])%mod
print((ans%mod))
# Original solution
N = int(eval(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])

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

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

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

print((ans % (10**9+7)  ))
# Original solution
N = int(eval(input()))
A_list = list(map(int, input().split()))
#myans_list =  [ [0 for n in range(N)] for nn in range(N) ]
#myans = 0
#for n in range(N):
#    for nn in range(N):
#        myans_list[n][nn] = A_list[n] * A_list[nn]
#for n in myans_list:
#    print(n)
myans = 0
for n in range(N-1):
    for nn in range(n+1, N):
        myans += A_list[n] * A_list[nn]
print((myans%(1000000007)))

# Optimized solution
N = int(eval(input()))
A_list = list(map(int, input().split()))
#myans_list =  [ [0 for n in range(N)] for nn in range(N) ]
#myans = 0
#for n in range(N):
#    for nn in range(N):
#        myans_list[n][nn] = A_list[n] * A_list[nn]
#for n in myans_list:
#    print(n)
mysum = sum(A_list)
myans = 0
for n in range(N-1):
    mysum -= A_list[n]
    myans +=  mysum*A_list[n]
print((myans%(1000000007)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
assert len(A) == N
total = 0
for i,ai in enumerate(A):
  total += ai * sum(A[i+1:])
print((total % (10 ** 9 + 7)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
assert len(A) == N
total = 0
sum_A = sum(A)
for i,ai in enumerate(A):
  sum_A -= ai
  total += ai * sum_A
print((total % (10 ** 9 + 7)))
# Original solution
n=int(eval(input()))
*a,=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]%(10**9+7)
sum_a=[]
for i in range(n):
    sum_a.append(sum(a)-sum(a[:i+1]))
b=0
for i in range(n):
    b+=sum_a[i]*a[i]
print((b%(10**9+7)))

# Optimized solution
n=int(eval(input()))
*a,=list(map(int,input().split()))
s=sum(a)%(10**9+7)
c=0
b=0
for i in range(n):
    b+=a[i]
    amod=a[i]%(10**9+7)
    c+=(s-b)*amod
print((c%(10**9+7)))
# Original solution
n = int(eval(input()))
alist = list(map(int,input().split()))
wa = 0
answer = 0
for i in range(n):
    for j in range(n-i-1):
        wa += alist[i+j+1]
    wa = wa % (10**9 + 7)
    answer += wa * alist[i]
    answer = answer % (10**9 + 7)
    wa = 0
print(answer)

# Optimized solution
n = int(eval(input()))
alist = list(map(int,input().split()))
wa = sum(alist)
answer = 0
atai = wa
for i in range(n):
    atai -= alist[i]
    answer += atai * alist[i]
    answer = answer % (10**9 + 7)
print(answer)
# Original solution
N = int(eval(input()))
A = [0] * N
A = list(map(int,input().split()))

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

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

com_A = [x * y for x,y in combinations(A,2)]
print((sum(com_A) % (10**9 + 7)))

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

com_A = [x * y % (10**9 + 7) for x,y in combinations(A,2)]
print((sum(com_A) % (10**9 + 7)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

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

# Optimized solution
N = int(eval(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)
# Original solution
import sys
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    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]
            ans %= MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


# Optimized solution
import sys
sys.setrecursionlimit(10**6)

MOD = 10**9+7


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

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


if __name__ == '__main__':
    main(sys.stdin.readline, print)
# Original solution
n = int(eval(input()))
li = list(map(int, input().split()))
res = 0
sum2 = 0
m = 10**9 + 7
for i in range(0, len(li)-1):
    sum2 += li[i]
    res = (res + li[i]*(sum(li)-sum2))%m
print(res)

# Optimized solution
n = int(eval(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)
# Original solution
# C Sum of product of pairs

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

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

# Optimized solution
# C Sum of product of pairs

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

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
mod = 1000000007
ans = 0
res = [A[0]]
for i in range(N-1):
    res.append(res[i]+A[i+1])
for i in range(1,N):
    ans = ans + (A[i]*res[i-1])%mod
ans = ans%mod
print(ans)
# Original solution
n=int(eval(input()))
mod=int(1e9)+7
l=[int(x) for x in input().split()]
sum1=0
for i in range(n-1):
    for j in range(i+1,n,1):
        prod=(l[i]*l[j])%mod
        sum1=(sum1%mod+prod%mod)%mod
print(sum1)


# Optimized solution
n=int(eval(input()))
mod=int(1e9)+7
l=[int(x) for x in input().split()]
sum1=0
sum2=0
for i in range(n):
    sum2=(sum2%mod+l[i]%mod)%mod
for i in range(n-1):
    sum2=sum2-l[i]
    x=(sum2%mod*(l[i]%mod))%mod
    sum1=(sum1%mod+(x%mod))%mod
print(sum1)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=0
c=0
for v in range(n-1):
  b+=a[v]
  c+=a[v]*(sum(a)-b)
print((c%(10**9+7)))  

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=sum(a)
c=0
for v in range(n-1):
  b-=a[v]
  c+=a[v]*b
print((c%(10**9+7)))
# Original solution
import sys
 
def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = list(map(int, input().split(" ")))
 
    mod = 10**9+7
    res = 0

    for i in range(N-1):
        for j in range(i, N):
            if i >= j: continue
            res += A[i] * A[j]
    print((res % mod))
if __name__ == "__main__":
    main()

# Optimized solution
import sys
 
def main():
    def input():return sys.stdin.readline()[:-1]
    N = int(eval(input()))
    A = list(map(int, input().split(" ")))
 
    mod = 10**9+7
    res = 0

    S = sum(A)
    S2 = sum([x**2 for x in A])
    print(((S**2-S2) // 2 % mod))
if __name__ == "__main__":
    main()