CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
ARR = list(map(int, input().split()))

def calculate(n, arr):
    mod = 1000000000 + 7
    result = 0

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

    print((result % mod))


calculate(N, ARR)


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

def calculate(n, arr):
    mod = 1000000000 + 7
    result = 0

    rightTotal = sum(arr)
    for i in range(n-1):
        rightTotal -= arr[i]
        result += (arr[i] * rightTotal) % mod

    print((result % mod))




calculate(N, ARR)
# Original solution
MOD = 1e9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
c = 0
for i in range(N):
    for j in range(i + 1, N):
        if i == j:
            continue
        c += (A[i] % MOD) * (A[j] % MOD)
        c %= MOD
print((int(c)))

# Optimized solution
MOD = 1000000007
N = int(eval(input()))
A = list(map(int, input().split()))
c = 0
S = 0
for a in A:
  S += a % MOD
  S %= MOD
for i in range(N):
    c += (A[i] % MOD) * ((S - A[i] % MOD) % MOD)
    c %= MOD
mod = pow(2, -1, 1000000007)
c = c * mod
c %= MOD
print((int(c)))
# Original solution
from itertools import accumulate
n = int(eval(input()))
A = list(map(int, input().split()))
MOD = 10**9+7

Acum = list(accumulate(A))
ans = 0
for i, a in enumerate(reversed(A[1:])):
    ans += Acum[n-i-2]*a
    ans %= MOD


print(ans)


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


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

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
mod = 1000000007
s = 0
S = sum(A)
for i in range(N - 1):
  S -= A[i]
  s += (A[i]*(S))%mod
print((s%mod))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
for i in range(n):
  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()))
arr = [0]*(n+1)
ans = 0
mod = 10**9+7
for i in range(n):
  arr[i+1] += arr[i]+a[i]
  
for i in range(n):
  ans += (a[i]*(arr[n]-arr[i+1]))%mod
print((ans%mod))
# Original solution
N = int(eval(input()))

A_list = [int(_) for _ in input().split()]

ans = 0
for i in range(len(A_list)):
    if i <= N-1:
        if A_list[i] == 0:
            continue
        j = i+1
        ans += sum([x*A_list[i]%(10**9+7) for x in A_list[j:N]])
        ans = ans%(10**9+7)
print(ans)

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

c = 10**9+7


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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


inv = modinv(2, c)

sum_of_a = sum(A_list) % c
sum_of_sq_a = sum([i**2 for i in A_list]) % c

ans = (sum_of_a**2 % c - sum_of_sq_a)*inv %c

print(ans)
# Original solution
##C - Sum of product of pairs
N = int(eval(input()))
A = list(map(int,input().split()))
import itertools
B = list(itertools.combinations(A,2))
print((sum (list([x[0] * x[1] for x in B])) % (10**9+7) ))

# Optimized solution
##C - Sum of product of pairs
##累積和
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    ans += A[i]*sum(A[i+1:])
print((ans % (10**9+7)))
# Original solution
import itertools

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

c = list(itertools.combinations(l, 2))

sum=0
for i in range(len(c)):
    sum+=c[i][0]*c[i][1]

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

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

sum=0
f=0

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

print((sum%(10**9+7)))
# Original solution
n = eval(input())

max = 10**9 + 7

a_list = [int(a) % max for a in input().split(" ")]

sum = 0
for i in range(0, len(a_list)-1):
  for j in range(i+1, len(a_list)):
    sum += a_list[i] * a_list[j]
    sum = sum % max
print(sum)


# Optimized solution
n = eval(input())
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    a_sum -= a_list[i]
    total += a_list[i] * a_sum
total = total % max
print(total)
# Original solution
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    n = int(eval(input()))
    a = readInt()
    ans = 0
    for i in range(n-1):
        for j in range(i+1,n):
            ans += a[i] * a[j]
            ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()



# Optimized solution
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    n = int(eval(input()))
    a = readInt()
    c_sum = [0]
    for i in range(n):
        c_sum.append(c_sum[i]+a[i])
    ans = 0
    for i in range(n-1):
        ans += a[i] * (c_sum[-1] - c_sum[i+1])
        ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()
# Original solution
import itertools

def main():
    N = int(eval(input()))
    A = [int(c) for c in input().split() if int(c) > 0]
    MOD = int(10**9+7)

    mono = 0
    bi = 0
    for x in A:
        mono += x
        #mono %= MOD
        bi += x**2
        #bi %= MOD
    ans = (mono**2 - bi)//2
    ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(c) for c in input().split() if int(c) > 0]
    MOD = int(10**9+7)
 
    mono = 0
    bi = 0
    for x in A:
        mono += x
        #mono %= MOD
        bi += x**2
        #bi %= MOD
    ans = (mono**2 - bi)//2
    ans %= MOD
    print(ans)
 
if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
pr=[a[i]*a[j] for i in range(len(a)-1) for j in range(i+1,len(a))]
print((sum(pr)%(10**9+7)))

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

# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print((ans%1000000007))
# Original solution
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(eval(input()))
a = list(map(int, input()[:-1].split(' ')))

MOD_VALUE = pow(10, 9) + 7
result = 0

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

if result < MOD_VALUE:
    print(result)
else:
    print((result % MOD_VALUE))


# Optimized solution
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(eval(input()))
a = list(map(int, input()[:-1].split(' ')))

MOD_VALUE = 10**9 + 7
result = 0

a_sum = sum(a)

for i, v in enumerate(a):
    result += v * (a_sum - v)
    a_sum -= v

if result < MOD_VALUE:
    print(result)
else:
    print((result % MOD_VALUE))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
M = 10**9 + 7
cnt = 0
for i in range(N):
    cnt += A[i] * sum(A[i+1:])
print((cnt%M))

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

S = sum(A)
S2 = sum([x**2 for x in A])
print((((S**2 - S2)// 2)%M))
# Original solution
from itertools import combinations
N=int(eval(input()))
A=list(map(int,input().split()))


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

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

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

zen=sum(A)


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

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

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

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

ans = 0
for i, j in C:
    ans += i * j
    ans = ans % (1e9 + 7)
print((int(ans)))


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

S = sum(A)
S2 = sum([x * x for x in A])

print(((S*S-S2)//2 % 1000000007))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

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

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

s = 0
mod = 10**9 + 7
for i in range(N-1):
    n = A[i] * A[i+1]
    n = n % mod
    s += n
    s %= mod
    A[i+1] += A[i]
print(s)
# Original solution
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

#print(a)
di = 10**9+7

s = 0
for i in range(N):
    for j in range(i+1,N):
        #print(a[i],a[j])
        s = (s + (a[i]*a[j])%di)%di
print(s)


# Optimized solution
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

#print(a)
di = 10**9+7
cum = [0]*(N+1)
for i in range(N)[::-1]:
    cum[i] = (cum[i+1] + a[i])%di

s = 0
for i in range(N):
    s = (s + (a[i]*cum[i+1])%di)%di
    # for j in range(i+1,N):
    #     #print(a[i],a[j])
    #     s = (s + (a[i]*a[j])%di)%di
print(s)

# import sys,collections
# sys.setrecursionlimit(1000000)
# INF = float("inf")

# Q = int(sys.stdin.readline())
# ab = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param
# N = 1000001

# cum=[0]*(N+1)

# for l,r in ab:
#     cum[l] += 1
#     if r+1 < N+1: cum[r+1] -= 1

# ret = cum[0]
# for i in range(N):
#     cum[i+1] += cum[i]
#     ret = max(ret,cum[i+1])

# print(ret)
# 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]
    
ans %= 10 ** 9 + 7
print(ans)

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

sum = sum(a) - a[0]

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

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

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

ans = 0

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

m = 10**9 + 7

ans = ans % m

print(ans)

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

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

ans = 0
sum = 0

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

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

m = 10**9 + 7

ans = ans % m

print(ans)
# Original solution
N = int(eval(input()))

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

MOD = 10 ** 9 + 7

x = 0
ans = 0
for i in range(len(A)):
    ans += A[i] * x % MOD
    x += A[i] % MOD
print((ans%MOD))    

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

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

MOD = 10 ** 9 + 7

max_edge = sum(A)

tmp = 0

for num in A:
    tmp += num ** 2

print(((max_edge ** 2 - tmp) // 2 % MOD))
# Original solution
import sys
input = sys.stdin.readline

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

for i in range(N):
    A[i] = A[i] % (1e9 + 7)

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

print((int(sum % (1e9 + 7))))



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

N = int(eval(input()))
A = list(map(int, input().split()))
mod = int(1e9+7)

sum = 0
row = 0
for ii in range(N-1):
    i = N-2-ii
    row += A[i+1]
    row %= mod
    sum += A[i] * row
    sum %= mod

print(sum)
# Original solution
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(eval(input()))
a=[int(x) for x in input().split()]
ans=0
for i in range(n):
    ans+=a[i]*sum(a[i+1:])
    ans%=mod
     
print(ans)

# Optimized solution
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(eval(input()))
a=[int(x) for x in input().split()]
cum_a=[]
for i in range(n):
    if i==0:cum_a.append(a[i])
    else:cum_a.append(cum_a[-1]+a[i])
ans=0
for i in range(n-1):
    ans+=a[i]*(cum_a[n-1]-cum_a[i])
    ans%=mod
     
print(ans)
# Original solution
# C

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

Asum=[sum(A[i+1:])%p for i in range(len(A))]
print((sum((A[i]*Asum[i])%p for i in range(N))%p))

# Optimized solution
# C

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

sumA = sum(A)

sumA_2 = sum([a**2 for a in A])

print((((sumA**2-sumA_2)//2)%p))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split())) 

goukei = 0
for i in range(N):
    a = A[0]
    del A[0]
    Agoukei = sum(A)
    goukei = goukei + a*Agoukei

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

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

sumA = sum(A)
for i in range(N):
    a = A[i]
    sumA = sumA - a
    goukei = goukei + sumA*a

k = 10**9 + 7
print((goukei%k))
# Original solution
N = int(eval(input()))
As = list([int(x) for x in input().split(" ")])

result = 0
MOD = 10**9+7

for i in range(len(As)-1):
    tmp = As[i] * (sum(As[i+1:]) % MOD)
    result += tmp
    result %= MOD

print(result)



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

result = 0
MOD = 10**9+7

S = sum(As)

for i in range(len(As)-1):
    S -= As[i]
    tmp = As[i] * S
    result += tmp
    result %= MOD

print(result)
# Original solution
n = int(eval(input()))
ar = list(map(int,input().split(" ")))
count = 0
for i in range(n-1):
    br = ar[i+1:n]
    count += ar[i] * sum(br)
print((count % (10 ** 9 + 7)))

# Optimized solution
n = int(eval(input()))
ar = list(map(int,input().split(" ")))
sm = sum(ar)
count = 0
for i in range(n-1):
    sm -= ar[i]
    count += ar[i] * sm
print((count % (10 ** 9 + 7)))
# Original solution
#!/usr/bin/env python3


def main():
    import itertools

    N, *A = list(map(int, open(0).read().split()))
    print((sum([v[0] * v[1] for v in itertools.combinations(A, 2)]) % (10 ** 9 + 7)))


main()


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


def main():
    import itertools

    N, *A = list(map(int, open(0).read().split()))
    # print(sum([v[0] * v[1] for v in itertools.combinations(A, 2)]) % (10 ** 9 + 7))
    s = 0
    for i in range(N):
        v1 = A[i]
        for v2 in A[i + 1 :]:
            s += v1 * v2
    print((s % (10 ** 9 + 7)))


main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
answer = 0

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

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

for i in range(N):
    sum_A -= A[i]
    answer += A[i] * sum_A % mod
print((answer % mod))
# Original solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

AA = [a % p for a in A]
sum = 0
for i in range(0, N - 1):
  for j in range(i + 1, N):
    sum += (AA[i] * AA[j]) % p
print((sum % p))

# Optimized solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
p = 10 ** 9 + 7

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

sum = 0
for i in range(0, N - 1):
	sum += (A[i] * (S[N - 1] - S[i])) % p
print((sum % p))
# Original solution
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
n=int(eval(input()))
A=INPUT()
sum=0
for i in range(n):
    for j in range(i+1,n):
        sum+=(A[i]*A[j])%J
        sum%=J
print((sum%J))


# Optimized solution
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
n=int(eval(input()))
A=INPUT()
sum=0
for i in range(n):
    sum+=A[i]
sum=sum*sum

s=0
for i in range(n):
    s+=A[i]**2

ans=(sum-s)//2
ans%=J
print(ans)
# Original solution
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)))

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

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

sum = 0
mod = 1000000000+7
for i in range(n):
    if a[i] >= mod:
        a[i] = a[i] % mod
for i in range(n-1):
    #if a[i] >= mod:
        #a[i] = a[i] % mod
    for j in range(i+1, n):
        #if a[j] >= mod:
            #a[j] = a[j] % mod
        sum = sum + a[i] * a[j]
        #print(sum)
        if sum >= mod:
            #print('no')
            sum = sum % mod
            #print(sum)
            #print('o')
print(sum)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
 
sum = 0
sum1 = 0
mod = 1000000000+7
for i in range(n):
    if a[i] >= mod:
        a[i] = a[i] % mod
    sum1 += a[i]
    sum1 %= mod
    
for i in range(n-1):
    #for j in range(i+1, n):
    sum1 -= a[i]
    #sum += a[i] * a[j]
    if sum1 < 0:
        sum1 += mod
    sum += a[i] * sum1
    sum %= mod
            
print(sum)
# Original solution
import itertools

n = int(eval(input()))
a = list(map(int,input().split()))
c = itertools.combinations(a, 2)
ini = [v[0]*v[1] for v in c]
print((sum(ini)%(10**9+7)))

# Optimized solution
import itertools

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

ini = [a[i]*sum(a[i+1:]) for i in range(n)]
print((sum(ini)%(10**9+7)))
# Original solution
import itertools

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

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

# Optimized solution
import itertools

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

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
MOD = 1000000007
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
N = int(eval(input()))
A = list(map(int, input().split()))
print((sum([A[i] * A[j] for i in range(N - 1) for j in range(i + 1, N)]) % (10 ** 9 + 7)))

# Optimized 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]
  total %= (10 ** 9 + 7)
print(total)