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

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

N = int(eval(input()))
A = [int(num)%mod for num in input().split()]

for i in range(N-1):

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

ans = int(ans%mod)
print(ans)

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

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

mod=10**9+7

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

# Optimized solution

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

mod=10**9+7

sumA=sum(A)

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

ans=ans//2
print((ans%mod))
# Original solution
N=int(eval(input()))
List = list(map(int, input().split()))
res=0
for i in range(N-1):
  a = List[i] % 1000000007
  for j in range(i+1,N):
    b =  List[j] % 1000000007
    res += a*b
print((res%1000000007))

# Optimized solution
N=int(eval(input()))
List = list(map(int, input().split()))
midList = [0]*(N-1)
mid = 0
for i in range(N-2,-1,-1):
  mid += List[i+1]
  midList[i] = mid
res=0
for i in range(N-1):
  a = List[i] % 1000000007
  b =  midList[i] % 1000000007
  res += a*b
print((res%1000000007))
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = LI()
mod = 10**9+7

ans = sum(A)**2
ans %= mod
a = sum(A[i]**2 for i in range(N))
a %= mod
ans -= a
ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)


# Optimized solution
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()
mod = 10**9+7

ans = sum(A)**2-sum(A[i]**2 for i in range(N))
ans %= mod
ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)
# Original solution
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()
mod = 10**9+7

ans = sum(A)**2-sum(A[i]**2 for i in range(N))
ans %= mod
ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)


# Optimized solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = LI()
s = sum(A)
mod = 10**9+7
s %= mod

a = s**2-sum(A[i]**2 for i in range(N))
a %= mod
a *= pow(2,mod-2,mod)
a %= mod

print(a)
# Original solution
from itertools import combinations

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

ans = 0
mod = 10**9 + 7

p = list(combinations(A,2))

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

print((ans%mod))


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

ans = 0
mod = 10**9 + 7

# p = list(combinations(A,2))

for i in range(len(A)-1):
    for j in range(i+1, len(A)):
        # ans += p[i][0] * p[i][1]
        #print(A[i], A[j])
        ans += A[i] * A[j]

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

# Optimized solution
n=int(eval(input()))
lst=list(map(int,input().split()))
aa=sum(lst) % (10**9+7)
# print(sum(lst) % (10**9+7) )
new_lst=[]
temp_1=aa
for i in range(n-1):
    temp_1-=lst[i]
    new_lst.append(temp_1)
# print(new_lst)

tem=0
for i in range(n-1):
    tem+=(lst[i] )*new_lst[i]
        # print(tem)
print((tem % (10**9 +7)))
# Original solution
mod=1000000007
n=int(eval(input()))
#n,k=map(int,input().split())
a=[int(i) for i in input().split()]
ans=chk=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=(a[i]*a[j])%mod
        ans%=mod
print(ans)

# Optimized solution
mod=1000000007
n=int(eval(input()))
#n,k=map(int,input().split())
a=[int(i) for i in input().split()]
t=[0]*(n+1)
for i in range(n):
    t[i]=t[i-1]+a[i]
ans=chk=0
#print(t)
for i in range(n-1):
#    print(-(i+1))
    x=-1*(i+1)
#    print(x)
#    print(a[x],t[x-2])
    ans+=a[x]*t[x-2]
    ans%=mod
print(ans)
# Original solution
n=int(eval(input()))
 
a=list(map(int,input().split()))
num=0
for i in range(n):
  for j in range(n-1,i,-1):
    num=num+a[i]*a[j]
else:
  print((num % 1000000007))

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

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

mod = 10**9+7

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

ans = 0
for i in range(n):
    ans += A[i] * (cs[-1]-cs[i])
    ans %= mod
print(ans)

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

mod = 10**9+7

x = (((sum(A))**2) // 2)
x -= (sum([a**2 for a in A]) // 2)
x %= mod
print(x)
# Original solution
import itertools

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

mod = (10**9)+7
comb = list(itertools.combinations(num_list, 2))
sum = 0
for tuple in comb:
    tmp = (tuple[0]*tuple[1])%mod
    sum += tmp

ans = sum%mod
print(ans)

# Optimized solution
import itertools

n = int(eval(input()))
num_list = list(map(int, input().split()))
lists = [i for i in num_list if i != 0]

mod = (10**9)+7
mod_list = []
sum = 0
for i in range(len(num_list)-1):
    for j in range(i+1, len(num_list), 1):
        if num_list[i] == 0 or num_list[j] == 0:
            continue
        else:
            tmp = (num_list[i]*num_list[j])%mod
            sum += tmp
ans = sum%mod
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

s = 0

m = 1000000007

for i in range(n):

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

s = s % m

print(s)


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

m = 1000000007

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

ans = ans//2
ans = ans % m

print(ans)
# Original solution
n = int(eval(input()))
li_a = list(map(int, input().split()))
answer = 0
mo = (10 ** 9) + 7
for idx, a in enumerate(li_a):
    answer += (a * sum(li_a[idx + 1:]))
print((answer % mo))

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

# Optimized solution
n = int(eval(input()))
aaa = list(map(int, input().split()))
mod = 1000000007
c_sum = [0] * n
c_sum[n - 1] = aaa[n - 1]
ans = 0

for i in range(n - 2, 0, -1):
    c_sum[i] = (c_sum[i + 1] + aaa[i]) % mod

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

print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0

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

# Optimized solution
MOD = 10 ** 9 + 7

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

s = sum(a) % MOD
ans = 0

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

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

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
b = 0
d = sum(a)
for m in range(n-1):
    d = d -a[m]
    b = b + a[m]*d
    if b >= 10**9+7:
        b = b % (10**9+7)
print(b)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split(" ")))

res = 0
for j in range(n):
    sum_i = 0
    for i in range(j):
        sum_i += a[i]
    res = res + a[j]*sum_i
print((res % ((10 **9)+7)))

# Optimized solution
n = int(eval(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)))
# Original solution
def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    a_list = []

    ans = 0
    for a in input().rstrip().split(" "):
        a = int(a)
        for past_a in a_list:
            ans += a * past_a
        a_list.append(a)
    x = 1000000007

    ans = ans % x

    print(ans)

if __name__ == "__main__":
    resolve()

# Optimized solution
def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    past_a = 0

    ans = 0
    for a in input().rstrip().split(" "):
        a = int(a)
        ans += a * past_a
        past_a += a

    x = 1000000007

    ans = ans % x

    print(ans)

if __name__ == "__main__":
    resolve()
# Original solution
N = int(eval(input()))
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
for i in range(N-1):
  p = As[i]
  cs_mod = sum(As[i+1:]) % m
  result += ((cs_mod * p) % m)
print((result % m))

# Optimized solution
N = int(eval(input()))
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
As_sum = sum(As)
for i in range(N-1):
  As_sum = As_sum - As[i]
  result += (As[i] * As_sum) % m

print((result % m))
# Original solution
import itertools
import operator

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

for i in range(len(list(itertools.combinations(A, 2)))):
    n = list(itertools.combinations(A, 2))
    if n[i][0]*n[i][1] >= (10**9+7):
        num = n[i][0]*n[i][1]%(10**9 +7)

    AA.append(n[i][0]*n[i][1])


if sum(AA) >= (10**9 +7):
    print((sum(AA)%(10**9 +7)))
else:
    print((sum(AA)))


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

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

for x in A:
    S -= x
    S %= mod
    ans += S * x
    ans %= mod

ans %= mod
print(ans)
# Original solution
MOD = 1000000007

n = int(eval(input()))
str_ary = input().split()
ary = [int(c) for c in str_ary]
# ary = []
# queue = [0 for i in range(n)]
# for i int range(n):
#   num = int(str_ary[i])
#   ary.append(num)
#   for j int range(i):
#     pre_queue = []
#     queue.append(pre_queue)

sum = 0
for diff in range(n - 1):
  for i in range(n - diff - 1):
    # print(i, i + diff + 1)
    sum += ary[i] * ary[i + diff + 1] % MOD
# for i in range(n):
#   sum = 0
#   for j in range(n - i - 1):
#     # print(i, j + i + 1)
#     sum += ary[j + i + 1]
#   result += ary[i] * sum

print((sum % MOD))

# Optimized solution
MOD = 1000000007

n = int(eval(input()))
str_ary = input().split()
ary = [int(c) for c in str_ary]
# ary = []
# queue = [0 for i in range(n)]
# for i int range(n):
#   num = int(str_ary[i])
#   ary.append(num)
#   for j int range(i):
#     pre_queue = []
#     queue.append(pre_queue)

result = 0
sum = sum(ary[i] for i in range(n))
# for diff in range(1, n):
#   for i in range(n - diff):
#     # print(diff, i, i + diff)
#     sum += ary[i] * ary[i + diff] % MOD
for i in range(n):
  sum -= ary[i]
  result += ary[i] * sum

print((result % MOD))
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    ans = 0

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

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


if __name__ == "__main__":
    main()


# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    s = sum(A)
    ans = 0
    mod = 10**9 + 7
    for i in A:
        ans = (ans + i * (s - i))
    print(((ans // 2) % mod))


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

from itertools import combinations

MOD = 10**9+7
result = 0
for seq in combinations(list(range(0, n)), 2):
  result += a[seq[0]] * a[seq[1]] % MOD
print((result%MOD))


# Optimized solution
n=int(eval(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))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0

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

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


# Optimized solution
n = int(eval(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)))
# Original solution
n=int(eval(input()))
mod=10**9+7
a=list(map(int,input().split()))


total=0

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

print(total)


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

A=sum(a)%mod
total=0

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

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


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
sum_a = 0
result = 0
for i in range(n):
  sum_a += a[i]
for j in range(n):
  sum_a -= a[j]
  result += sum_a * a[j]
print((result % (10**9 + 7)))
# Original solution
def solve():
  N = int(eval(input()))
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  ans = ans % (10**9+7)
  for a in AA:
    aa = (a**2) % (10**9+7)
    ans -= a**2
    while ans<0:
      ans += 10**9+7
  ans = ans % (10**9+7)
  print((int(ans/2)))
solve()

# Optimized solution
def solve():
  N = int(eval(input()))
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print((ans%(10**9+7)))
solve()
# Original solution
def main():
    n=int(eval(input()))
    a=sorted(map(int,input().split()), reverse=True)
    ans=0
    mod=10**9+7
    for i in range(n-1):
        if a[i] == 0:
            break
        for j in range(i+1,n):
            if a[j] == 0:
                break
            ans += a[i]*a[j]%mod
    print((ans%mod))

if __name__ == '__main__':
    main()

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

if __name__ == '__main__':
    main()
# Original solution
from itertools import accumulate
def main():
    mod=10**9+7
    n=int(eval(input()))
    a=list(map(int,input().split()))
    aa=[0]+list(accumulate(a))
    ans=0
    for i in range(n-1):
        ans += a[i]*(aa[-1]-aa[i+1])%mod
    print((ans%mod))

if __name__ == '__main__':
    main()

# Optimized solution
from itertools import accumulate
def main():
    n=int(eval(input()))
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print((ans%mod))
    
if __name__ == "__main__":
    main()
# Original solution
def main():

    from builtins import input, int, map

    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)

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

main()

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

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

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

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


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

"""
allsum = 0
for i in range(n-1):
    allsum += a[i] * sum(a[i+1:])
print(allsum % (10**9+7))
"""
s, s2 = 0, 0
for i in range(n):
    s += a[i]
    s2 += a[i] * a[i]
print((((s*s - s2)//2) % (10**9+7)))
# Original solution
mod = 10 ** 9 + 7
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):
        prod = (a[i] * a[j]) % mod
        ans += prod
        ans %= mod

print(ans)

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

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


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

print(ans)
# Original solution
import itertools
n = int(eval(input()))
a = list(map(int,input().split()))
cnt = 0
for i,j in itertools.combinations(a,2):
    cnt += i*j
print((cnt % (10**9 + 7)))

# Optimized solution
import itertools
n = int(eval(input()))
a = list(map(int,input().split()))
ruisekiwa = [0] * n
cnt = 0
ruisekiwa[0] = a[0]
for i in range(1,n):
    ruisekiwa[i] = ruisekiwa[i-1] + a[i]
for i in range(n):
    cnt += a[i] * (ruisekiwa[-1] - ruisekiwa[i])
print((cnt % (10**9 + 7)))
# Original solution
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

mod=10**9+7
n=int(eval(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))

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

import sys
input=sys.stdin.readline

mod=10**9+7
n=int(eval(input()))
arr=list(map(int,input().split()))
ans=sum(arr)*sum(arr)
for val in arr:
    ans-=(val*val)%mod
print(((ans*pow(2,-1,mod))%mod))
# Original solution
import sys
def input():
    return sys.stdin.readline()[:-1]


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

    
if __name__ == "__main__":
    main()

# Optimized solution
import sys
def input():
    return sys.stdin.readline()[:-1]


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

answer = 0
mod = 1000000007
for i in range(N-1):
  total = sum(A[i+1:])
  multi = ((A[i] % mod) * (total % mod)) % mod
  answer = (answer + multi) % mod
print((str(answer)))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print((str(answer % mod)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
 
answer = 0
mod = 1000000007
for i in range(N-1):
  total = sum(A[i+1:])
  multi = A[i] * total
  answer += multi
print((str(answer % mod)))

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

# Optimized solution
def main():
    MOD = 10**9 + 7
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a_sum = sum(a)
    ans = 0
    
    for i in range(n):
        ans += a[i] * (a_sum - a[i])
    print((ans // 2 % MOD))
        
        
if __name__ == '__main__':
    main()
# Original solution
def main():
    MOD = 10**9 + 7
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = 0
    
    a_sum = []
    for i in range(n):
        a_sum.append(sum(a[i+1:n]))
    
    for i in range(n-1):
        ans += a[i] * a_sum[i]
        ans %= MOD
    print(ans)
        
        
if __name__ == '__main__':
    main()

# Optimized solution
def main():
    MOD = 10**9 + 7
    n = int(eval(input()))
    a = list(map(int, input().split()))
    ans = 0
   
    a_sum = sum(a)
    
    for i in range(n-1):
        a_sum -= a[i]
        ans += a[i] * a_sum
        ans %= MOD
    print(ans)
        
        
if __name__ == '__main__':
    main()
# Original solution
import copy

N = int(eval(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)))


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

partial_sum = A.copy()
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)))
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
s=0
for i in range(n-1):
    for j in range(i+1,n):
        s+=l[i]*l[j]
print((s%(10**9+7)))

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

N = int(eval(input()))
A = list(map(int,(input().split())))
Asum = 0
c_list = list(itertools.combinations(A, 2))

for l in c_list:
    Asum = Asum + l[0]*l[1]

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,(input().split())))
total = 0
result = 0
MOD = pow(10,9)+7
l = []

for i in range(N):
    total += A[i]
    l.append(total)#累積和

for i,num in enumerate(l):
    temp = total-num #A[i+1]+A[i+2]+...+A[N]
    result += temp*A[i]#A[i](A[i+1]+A[i+2]+...+A[N])の総和

print((result%MOD))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9+7
listsum = 0
for i in range(n-1):
    for j in range(i+1,n):
        listsum += a[i]*a[j]%mod
        listsum = listsum%mod
print(listsum)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9+7
listsum = sum(a)
kotae = 0
for i in range(n-1):
    listsum -= a[i]
    kotae += listsum*a[i]%mod

print((kotae%mod))