CodeEff/ECCO huggingface dataset:
# 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])%(10**9+7)
ans=ans%(10**9+7)
print(ans)


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


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

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
i = 0
tmp = 0
tmpura = 0
while(i < n):
    tmp += a[i]
    i+=1
tmp=tmp **2
i = 0
while (i < n):
    tmpura += a[i]**2
    i+=1
tmpura=tmpura
ans = ((tmp - tmpura)//2)%(10**9+7)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
SUMA = sum(A)
MOD = 10**9 + 7
C = [0] * (N-1)
for i in range(N-1):
  SUMA -= A[i]
  C[i] = SUMA
ans = 0
for i in range(N-1):
  ans += A[i]*C[i]
  ans %= MOD
print(ans)

# Optimized solution
N = int(eval(input())) #入力する整数
A = list(map(int,input().split())) #入力する数列A
SUMA = sum(A) #数列の和
MOD = 10**9 + 7 # mod
C = [0] * (N-1) #累積和数列
for i in range(N-1): #\sum_{j = i+1}^{N}を求めて数列に代入する
  SUMA -= A[i]
  C[i] = SUMA
ans = 0 #求める答え
for i in range(N-1):
  ans += A[i]*C[i]
  ans %= MOD #その都度modで割った余りにする
print(ans) #答えを出力する

#計算量はO(N)です。
# Original solution
N = int(eval(input()))
As = list(map(int, input().split()))
S = 0
for i in range(N - 1):
  T = 0
  for j in range(N - i - 1):
    # print(As[i], As[i + 1 + j])
    T += As[i + 1 + j]
  T = T % 1000000007
  S += As[i] * T
print((S % 1000000007))

# Optimized solution
N = int(eval(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))
# Original solution
N=int(eval(input()))
A=list(map(int, input().split()))
p,S = 0,0
for i in range(N-1):
    ap = A.pop(0)
    AA = sum(A)
    aa = ap*AA
    a = aa%1000000007
    S += a
p = S%1000000007
print(p)

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

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

p = list(itertools.combinations(list(range(n)), 2))

ans = 0
for i in p:
    ans += a[i[0]] * a[i[1]]

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

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

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

ans = int(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):
    ans += a[i] * sum(a[i+1:])

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

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

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

ans = int(ans % (10**9+7))
print(ans)
# Original solution
import itertools

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

result = 0

for a, b in itertools.combinations(a, 2):
    result += a*b % 1000000007
print((result % 1000000007))

# Optimized solution
n = int(eval(input()))
a = [int(each) for each in input().split()]

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

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

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

print(ans)


# Optimized solution
M = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))

print(((((sum(A)**2) - sum([x*x for x in A])) // 2) % M))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0
x = 0
y = 0
for i in range(n - 1):
    B = A[i + 1:n]
    x = sum(B) % z
    y = (A[i] * x) % z
    ans = (ans + y) % z

print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0

x = sum(A)
x = x ** 2
for i in A:
    y = i * i
    x -= y

x = x // 2
x = x % z
print(x)
# Original solution
import itertools
n=int(eval(input()))
A=list(map(int,input().split()))
AC=list(itertools.combinations(A,2))
for i in range(len(AC)):
  AC[i]=AC[i][0]*AC[i][1]%(10**9+7)
print((sum(AC)%(10**9+7)))

# Optimized solution
import itertools
n=int(eval(input()))
A=list(map(int,input().split()))
AC=list(itertools.combinations(A,2))
x=0
for i in range(n*(n-1)//2):
  x+=AC[i][0]*AC[i][1]%(10**9+7)
print((x%(10**9+7)))
# Original solution
n=int(eval(input()))
A=list(map(int,input().split()))
x=0
for i in range(n-1):
  for j in range(i+1,n):
    x+=A[i]*A[j]%(10**9+7)
print((x%(10**9+7)))

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

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

# Optimized solution
n = int(eval(input()))
a = [int(s) for s in input().split()]
b = []
val = 0
sum_val= 0
for i in range(0, n):
    b.append(a[i] * sum_val) 
    sum_val+= a[i] 
val = sum(b)
print((val % (10 ** 9 + 7)))
# Original solution
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    target = LI()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += (target[i] % MOD) * (target[j] % MOD) % MOD
            ans = ans % MOD
    print(ans)


main()


# Optimized solution
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return list(map(int, sys.stdin.readline().split()))


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    target = LI()

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

    for i in range(N):
        ans += target[i] * (sum_all - sums[i])
        ans = ans % MOD

    print(ans)


main()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split(" ")))

ans = 0
den = int(1e9 + 7)
for i in range(len(a) - 1):
    ans = (ans + a[i] * sum(a[i + 1:])) % den

print(ans)

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

ans = 0
den = int(1e9 + 7)
sum_a = [0 for i in range(len(a))]
sum_a[-1] = a[-1]
for i in range(len(a) - 1, 1, -1):
    sum_a[i - 1] = sum_a[i] + a[i - 1]
for i in range(len(a) - 1):
    ans = (ans + a[i] * sum_a[i + 1]) % den

print(ans)
# Original solution
import itertools

mod = 1000000007
sum = 0
N = int(eval(input()))
A = list(map(int, input().split()))
for v in itertools.combinations(A, 2):
    sum += v[0] * v[1]
print((sum%mod))


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

mod = 1000000007
S = {}
S[0] = A[0]
for i in range(1, len(A)):
    S[i] = S[i-1] + A[i]

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

B=[0]*N
c=0

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

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

c=0
for i in range(N):
    c=c+A[i]**2
    
print(((sum(A)**2-c)//2%(10**9+7)))
# Original solution

from itertools import accumulate
def resolve():
    MOD = 10**9+7
    N = int(eval(input()))
    A = list(map(int, input().split()))

    Acc = [0] + list(accumulate(A))

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

    print(ans)


if __name__ == "__main__":
    resolve()


# Optimized solution

def resolve():
    MOD = 10 ** 9 + 7
    N = int(eval(input()))
    A = list(map(int, input().split()))

    # 面積として見る: 縦*横
    square = sum(A) ** 2

    # 対角線
    diag = sum([a * a for a in A])

    ans = (square - diag) // 2
    print((ans % MOD))


if __name__ == "__main__":
    resolve()
# Original solution
N = int(eval(input()))
suji = list(map(int, input().split()))

goukei = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        goukei += suji[i] * suji[j]

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

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

wa = sum(suji)
goukei = 0

for i in range(N):
    goukei += suji[i] * (wa - suji[i])
    wa -= suji[i]

print((goukei % (10 ** 9 + 7)))
# Original solution
mod = 10**9 + 7
n = int(eval(input()))
nums = list(map(int, input().split(" ")))

ans = 0

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

print((ans % mod))

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

ans = 0

ans = sum(nums) * sum(nums) - sum([num*num for num in nums])

print(((ans // 2) % mod))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
b=0

for i in range(0,N):
    if A[i]%(10**9)+7==0:
        del A[i]

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

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

for j in range(0,len(A)):
    c+=A[j]

for i in range(0,len(A)):
        c=c-A[i]
        b+=A[i]*c
        
print((b%(10**9+7)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

ans=0
for i in range(n):
  p=a.pop()
  q=sum(a)
  ans+=p*q
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):
  s-=a[i]
  ans+=s*a[i]
print((ans%(10**9+7)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

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

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

A=sum(a)
ans=0
for i in range(n):
  A-=a[i]
  ans+=A*a[i]
print((ans%(10**9+7)))
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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

A = [a % MOD for a in A]

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

print(res)

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

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

A = [a % MOD for a in A]
A_d = [(a * a) % MOD for a in A]
res = ((sum(A)**2) % MOD - sum(A_d) % MOD) % MOD
res = res * pow(2, MOD-2, MOD)
res %= MOD

print(res)
# Original solution
import itertools


def main():
    count = 0
    n = int(eval(input()))
    for i in itertools.combinations(list(map(int, input().split())), 2):
        count += i[0]*i[1]
    return count % (10**9+7)


if __name__ == "__main__":
    print((main()))


# Optimized solution
import itertools


def main():
    count = 0
    MOD = 10**9+7
    n = int(eval(input()))
    a = list(map(int, input().split()))
    s = [0]
    for i in range(n-1):
        s.append((s[i]+a[i]) % MOD)
    for ai, si in zip(a, s):
        count += (ai*si) % MOD
    return count % MOD


if __name__ == "__main__":
    print((main()))
# 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
        ans=ans%mod

print((ans%mod))



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

tmp=a[-1]
ans=0
for i in range(n-1):
    ii=n-i-2
    #print(ii)
    ans+=(tmp*a[ii])%mod
    ans=ans%mod
    tmp+=a[ii]%mod

print((ans%mod))
# Original solution
N = int(eval(input()))
A = list(int(x) for x in input().split())
a = len(A)
sa = sorted(A)
su = 0
p = 10**9+7
for i in range(a):
        su += sa[i]*(sum(sa[i+1:])%p)%p

print((su%p))


# Optimized solution
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = [0]
a = len(A)
sa = sorted(A)
su = 0
p = 10**9+7

for i in range(a):
    B.append(B[i] + sa[i])

for j in range(a):
    su += sa[j]*B[j]

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

# Optimized solution
from collections import deque
N = int(eval(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)))
# Original solution
n = int(eval(input()))
arr = list(map(int,input().split()))
ans = 0
for i in range(len(arr)):
    for j in range(i+1,len(arr)):
        ans += (arr[i]*arr[j])%(1000000007)
        ans %= 1000000007
print(ans)

# Optimized solution
n = int(eval(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))
# Original solution
N = int(eval(input()))
A_list = tuple(map(int, input().split(' ')))

# print(N)
# print(A_list)

ret = 0
now_sum = sum(A_list)
# print("スタート{}".format(now_sum))

for i in range(len(A_list)):
  now_sum -= A_list[i]
  multiple_base = A_list[i]
  # print('now_sumから{0}を引いて{1}'.format(A_list[i], now_sum))
  before_total = 0
  for q in range(i + 1, len(A_list)):
    before_total += A_list[q]
  # print("before_totalは{0}, multiple_baseは{1}, 掛け算で{2}".format(multiple_base, before_total, multiple_base * before_total))
  ret += multiple_base * before_total
  
print((ret % 1000000007))


# Optimized solution
N = int(eval(input()))
A_list = tuple(map(int, input().split(' ')))

# print(N)
# print(A_list)

ret = 0
now_sum = sum(A_list)
# print("スタート{}".format(now_sum))

for i in range(len(A_list)):
  now_sum -= A_list[i]
  multiple_base = A_list[i]
  # print('now_sumから{0}を引いて{1}'.format(A_list[i], now_sum))
  before_total = 0
  # print("before_totalは{0}, multiple_baseは{1}, 掛け算で{2}".format(multiple_base, before_total, multiple_base * before_total))
  ret += multiple_base * now_sum
  
print((ret % 1000000007))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
T=0
x=0
L=10**9+7

for i in range(0,N):
    for j in range(i+1,N):
        x=x+A[j]
    y=A[i]*x
    T+=y
    x=0

ans=T%L
print(ans)


# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
MOD=10**9+7 #先に書いておく

s=[0] #sのリスト(累積和)
for i in range(0,N): #累積和を作る
    s.append(s[i]+A[i])

sum=0
for j in range(0,N): #合計をだす
    sum+=A[j]*(s[N]-s[j+1])

ans=sum%MOD #10^9+7で割った余りが答え
print(ans)
# Original solution
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i]) % MOD
    ans %= MOD
print(ans)


# Optimized solution
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i]) % MOD
print((ans%MOD))
# Original solution
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i]) % MOD
print((ans%MOD))


# Optimized solution
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i])
print((ans%MOD))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
mod = 10**9 + 7

s = [0]*n
for i in range(n):
    s[i] = sum(a[i+1:]) % mod
# print(s)

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

print((ans % mod))

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

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

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

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

mod = (10**9)+7
goukei = 0

for i in range(N-1):
  Ai = A[i]
  AJ = A[i+1:]
  goukei += sum(AJ)*Ai
  goukei = goukei%mod

print(goukei)

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

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

mod = (10**9)+7
sumA = sum(A)%mod
sumSq = sum([(i*i)%mod for i in A])%mod
r = (((sumA*sumA)%mod)-sumSq) * modinv(2, mod)
print((r%mod))
# Original solution
import itertools

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

ans = 0

B = list(itertools.combinations(A,2))

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

ans %= MOD

print(ans)

# Optimized solution
MOD = 1000000007
 
N = int(eval(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)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

k = 1000000007

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

if ans>1000000007:
    print((ans%k))
else:
    print(ans)

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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print((ans%k))
else:
    print(ans)
# Original solution
N = int(eval(input()))
Alst = list(map(int, input().split()))
ans = 0
l = len(Alst)
for i in range(l):
    ans = (ans + Alst[i]*sum(Alst[i+1:]))%(10**9 +7)

print(ans)

# Optimized solution
N = int(eval(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)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

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


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

mod = 10 ** 9 + 7

sum_a=0
for i in A:
    sum_a+=i
    sum_a%=mod

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

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in A:
    for j in A:
        ans += (i*j) % (10**9+7)
mi = sum([x ** 2 for x in A])
ans -= mi
ans = ans % (10**9+7)
print((int(ans/2)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

S = [0 for _ in range(N+1)]
mod = 1000000007

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

print((int(S[N-1] % mod)))

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

S = [0 for _ in range(N+1)]
T = [0 for _ in range(N+1)]
mod = 1000000007

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

print((int(S[N-1] % mod)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

comb = len(a) * (len(a) - 1) / 2
comb = int(comb)

sum = 0

for i in range(comb):
    #print(a)
    for i in range(1, len(a)):
        #print(a[i])
        sum = sum + a[0] * a[i]
    a = a[1:]
    #print(a)

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

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

N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
cnt = 0
for x,y in combinations(A,2):
    z = x * y % mod
    cnt += z
print((cnt % mod))

# Optimized solution
N = int(eval(input()))
A = [0] + list(map(int, input().split()))
mod = 10**9 + 7

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

ans=0
for i in range(N):
       ans+=S[i]*sum(S[i+1:])
print((ans%t))    

# Optimized solution
N=int(eval(input()))
*A,=list(map(int,input().split()))
t=10**9+7
S=[a%t for a in A]
g=sum(S)

ans=0
for i in range(N):
       g-=S[i]
       ans+=S[i]*g%t
print((ans%t))
# Original solution
import sys
BIG = 10**9 + 7
def sumpp(n,a):
    acc = 0
    for i in range(n-1):
        acc += a[i] * sum(a[i+1:])
    return acc % BIG
input = sys.stdin.readline
if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int,input().split()))
    print((sumpp(n,a)))


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

def sumpp(n,a):
    acc = 0
    tmp = 0
    sumv = sum(a)
    for i in range(n):
        tmp += a[i]
        acc += a[i] * (sumv - tmp)
    return acc % BIG

if __name__ == "__main__":
    n = int(eval(input()))
    a = list(map(int,input().split()))
    print((sumpp(n,a)))
# Original solution
N = int(eval(input()))
A = [ int(v) for v in input().split(" ") ]

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

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

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

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

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