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


# Optimized solution
times = int(eval(input()))
numbers = list(map(int, input().split()))
result = 0
sum_numbers = sum(numbers)
calc = []

for i in range(times - 1):
  sum_numbers -= numbers[i]
  calc.append(sum_numbers)

for i in range(times - 1):
  calc[i] *= numbers[i]
  
print((sum(calc) % (10 ** 9 + 7)))
# Original solution
N = int(eval(input()))
Al = input().split()
A = list( map((lambda x: int(x)), Al))
num = 0
ma = 10**9 + 7

for i in range(N):
  num = (num + A[i]*sum(A[i+1:])) % ma

print(num)


# Optimized solution
N = int(eval(input()))
Al = input().split()
A = list( map((lambda x: int(x)), Al))
num = 0
ma = 10**9 + 7
li = 0

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

num = num % ma
print(num)
# Original solution

import itertools
x = 10**9 + 7
n = int(eval(input()))
a = list([i % x for i in list(map(int, input().split(" ")))])

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += (a[i] * a[j]) % x
print((ans % x))

# Optimized solution
import itertools
x = 10**9 + 7
n = int(eval(input()))
a = list([i % x for i in list(map(int, input().split(" ")))])
sum_a = []
prev = 0
for i in a:
    sum_a.append(prev + i)
    prev = prev + i

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

print(sum)


# Optimized solution
n=int(eval(input()))
sums=0
a=list(map(int, input().split()))
b = sum(a)
for i in range(n):
  b -= a[i]
  sums += a[i]*b
  sums = sums%((10**9)+7)
print(sums)
# Original solution
from collections import defaultdict
N=int(eval(input()))

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

P=1000000007

z=0
bm=defaultdict(lambda:0)

for i in range(0,N-1):
    for j in range(i+1,N):
        if(0!=bm[(A[i],A[j])]):
            p=bm[(A[i],A[j])]
        else:
            p=A[i]*A[j]
            bm[(A[i],A[j])]=p
#        print(i,j,p)
        z+=p

z%=P
print(z)


# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
s=sum(A)
ss=s
z=0
for i in range(0,N-1):
    ss-=A[i]
    z+=A[i]*ss

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

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

mod = (10**9) +7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        t = (lis[i]*lis[j])
        ans += t

print((ans%mod))

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

mod = 10**9+7

s = sum(lis)
tmp = 0
for i in lis:
    tmp += i**2

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

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


def mod(val):
    res = val % (10 ** 9 + 7)
    if (res < 0):
        res += (10 ** 9 + 7)
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int, _in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_mod = [0] * len(A_arr)
    for i, a in enumerate(A_arr):
        A_arr_mod[i] = mod(a)

    ans = 0
    for i in range(N-1):
        ans += A_arr_mod[i] * sum(A_arr_mod[i+1:])
    ans = mod(ans)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
from sys import stdin


def mod(val):
    res = val % (10 ** 9 + 7)
    if (res < 0):
        res += (10 ** 9 + 7)
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int, _in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_mod = [0] * len(A_arr)
    for i, a in enumerate(A_arr):
        A_arr_mod[i] = mod(a)

    ans = 0
    cache = sum(A_arr_mod)
    for i in range(N-1):
        cache -= A_arr_mod[i]
        ans += A_arr_mod[i] * cache
        ans = mod(ans)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
import sys
si = sys.stdin.readline


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    mod, ans = 10**9+7, 0
    for i in range(n):
        for j in range(i+1, n):
            ans = (ans+(l[i]*l[j]) % mod) % mod
    print(ans)


if __name__ == '__main__':
    main()


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


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    tot = sum(l)
    mod, ans = 10**9+7, 0
    for i in range(n-1):
        h = l[i]
        tot -= h
        ans = (ans+(tot*h) % mod) % mod
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline
mod = int(1e9+7)
n=int(eval(input()))
L=list(map(int,input().split()))
total = 0
for i in range(n):
    for j in range(i+1,n):
        total+=((L[i]%mod)*(L[j]%mod))%mod
print((total%mod))





# Optimized solution
import sys
input = sys.stdin.readline
mod = int(1e9+7)
n=int(eval(input()))
L=list(map(int,input().split()))
total = 0
hb = sum(L)
val = 0
for i in range(n-1):
    val +=L[i]
    total += L[i]*(hb-val)
print((total%mod))
# Original solution
n=int(eval(input()))
L=[int(x) for x in input().split()]
sum=0
mod=1000000007
for i in range(n-1):
    for j in range(i+1,n):
        sum+=(L[i]*L[j])%mod
print((sum%mod))


# Optimized solution
n=int(eval(input()))
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print((product%mod))
# Original solution
#!/usr/bin/env python3
N = int(eval(input()))
A = list(map(int, input().split()))

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


# Optimized solution
#!/usr/bin/env python3
N = int(eval(input()))
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

s = sum(A)** 2

a = 0
for i in A:
    a += (i ** 2)

ans = (s - a) // 2
ans = ans % mod

print(ans)
# Original solution
def main():
    eval(input())  # n
    array = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7
    ans = 0
    for i, ai in enumerate(array):
        for aj in array[i + 1:]:
            ans += ai * aj
            ans %= mod
    return ans


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


# Optimized solution
from itertools import accumulate


def main():
    n = int(eval(input()))
    array = [int(x) for x in input().split()]
    acc = accumulate(array)
    mod = 10 ** 9 + 7
    ans = 0
    for i, ai in enumerate(acc):
        if i == n - 1:
            continue
        ans += ai * array[i + 1]
        ans %= mod
    return ans


if __name__ == '__main__':
    print((main()))
# Original solution
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return eval(input())
def i(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

# Optimized solution
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return eval(input())
def i(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
ans = 0
num = sum(A)
for i in range(N-1):
     num -= A[i]
     ans = (ans+A[i]*num)%mod
print(ans)
# Original solution
import itertools

if __name__ == '__main__':

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

	total = 0
	C = list(itertools.combinations(A, 2))
	B = [v[0]*v[1] for v in C]
	print((sum(B)%(10**9+7)))


# Optimized solution
if __name__ == '__main__':

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

    #全体
    sm = sum(A) ** 2
    #共通部分
    com = sum([i * i for i in A])

    ans = (sm - com) // 2
    print((ans%(10**9+7)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

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


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

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

ans = 0
for i in range(n-1):
    aa = a.pop()
    # print(a,aa)
    ans +=  (aa * sum(a)) % mod
    ans %= mod

print((ans%mod))

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

ans = 0
aa = 0
for i in range(n-1):
    aa += a.pop()
    # print(a,aa)
    ans +=  (aa * a[-1]) % mod
    ans %= mod

print((ans%mod))
# 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]) % 1000000007) + total) % 1000000007

print(total)


# Optimized solution
mod = 1000000007

n = int(eval(input()))
a = list(map(int, input().split(' ')))
b = [0] * (n + 1)

for i, v in enumerate(a):
    b[i+1] = (b[i] + v) % mod

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

print(ans)
# Original solution
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    mod = 10**9 + 7

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

    print(answer)

main()



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

sq_sum = sum([x*x for x in A])
sum_sq = sum(A) * sum(A)
answer = (sum_sq - sq_sum) // 2

print((answer % mod))
# Original solution
n = int(eval(input()))
A = [*list(map(int, input().split()))]
MOD = (10**9)+7
ans = 0

# print(A)

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

# print(sum_a)

for i in range(n):
    ai = A[i]
    ans = (ans + ai*(sum_a[-1] - sum_a[i+1])) % MOD
    # print(sum_a[-1], sum_a[i+1],sum_a[-1] - sum_a[i+1] )

# for i in range(n):
#     for j in range(i+1, n):
#         ans = (ans + A[i]*A[j]%MOD) % MOD
ans = (ans + MOD) % MOD
print(ans)


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


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


# Optimized solution
n = int(eval(input()))
A = [*list(map(int, input().split()))]
MOD = 10**9 + 7
ans = b = 0
for a in A:
    ans += a * b
    ans %= MOD
    b += a
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

mod = 1000000000 + 7
ans = 0

for i in range(n):
    for j in range(i+1,n,1):
        pdt = 0
        if i<j:
            pdt = a[i] * a[j]
        ans %= mod
        ans += pdt

ans %= mod
print(ans)

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

mod = 1000000000 + 7
ans = 0

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

ans %= mod
print(ans)
# Original solution
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )
    A_list = list(map(int, sys.stdin.readline().split()))
    
    
    mod = 10**9 + 7
    S = 0

    for i in range(len(A_list)-1):
        for j in range(i+1, len(A_list)):
            S += ( A_list[i] * A_list[j] ) % mod
            S %= mod
    
    print(S)


if __name__ == "__main__":
    main()


# Optimized solution
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )
    A_list = list(map(int, sys.stdin.readline().split()))
    
    cum_sum = 0
    A_cum_sum = []

    for i in range(len(A_list)):
        cum_sum += A_list[i]
        A_cum_sum.append(cum_sum)


    mod = 10**9 + 7
    S = 0

    for i in range(len(A_list)):
        S += A_list[i] * ( A_cum_sum[-1] - A_cum_sum[i] )
        S %= mod
    
    print(S)


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

MOD = 10**9 + 7
A_mod = [a%MOD for a in A]

ans = 0

for i in range(1, N):
    ans = (ans + A_mod[i-1]%MOD * sum(A_mod[i:])%MOD)%MOD
    
print(ans)

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

MOD = 10**9 + 7
A_mod = [a%MOD for a in A]

R = sum(A_mod)

ans = 0

for a in A_mod:
    R -= a
    ans = (ans + a%MOD * R%MOD)%MOD
    
print(ans)
# Original solution
n = int(eval(input()))
lst = [ int(i) for i in input().split() ]
count = 0
for i in range(len(lst)):
    c = 0
    for j in range(i+1, len(lst)):
        c += lst[j]
    count += c * lst[i]
    
mod = 10**9 +7
if count >= mod:
    print((count%mod))
else:
    print(count)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print((count%mod))
else:
    print(count)
# Original solution
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
min = 0

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


print((ans % 1000000007))


# Optimized solution
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
min = 0
new_list = list(reversed(a))

for i in range(len(new_list) - 1):
    min += new_list[i]
    ans +=  min * new_list[i+1]


print((ans % 1000000007))
# Original solution
n = int(eval(input()))
x = [int(w) for w in input().split()]

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

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

ans = 0
mod = 10**9 + 7
s = sum(x)

for i in range(n):
    ans += ((x[i])**2)

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

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
tasizann = 0
for i in range (N):
 tasizann = tasizann + A[i]
nijou = tasizann**2
nijouwa = 0
for i in range (N):
 nijouwa =nijouwa + A[i]**2
ans = (nijou - nijouwa)//2
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):
    for j in range(i + 1, n):
        ans += a[i] % (10 ** 9 + 7) * a[j] % (10 ** 9 + 7)
print((ans % (10 ** 9 + 7)))

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

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

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

limit=10**9+7
S=[0]
for i in range(N):
    A[i]=A[i]%limit
for i in range(1,N):
    S.append((S[i-1]+A[-i])%limit)
ans=0
for i in range(N-1):
    ans+=A[i]*S[-1-i]
    ans=ans%limit
print(ans)
# Original solution
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0
    for i, ai in enumerate(A):
        for j, aj in enumerate(A[i+1:]):
            ans += (ai * aj) % MOD
    
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0

    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)

    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i]) % MOD
    
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
# Original solution
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0

    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)

    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i]) % MOD
    
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0

    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)

    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i])
    
    print((ans % MOD))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
# Original solution
count = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
sum = 0

for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    temp = a[i] * a[j]
    sum += temp

answer = sum % mod
print(answer)


  

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

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

M = 10**9 + 7

for n in range(N):
    A[n] = A[n] % M

ans = 0

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

print(ans)

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

M = 10**9 + 7

Total = sum(A) -A[0]

ans = 0

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

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

ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += al[i]*al[j]
        ans %= 10**9+7

print(ans)

# Optimized solution
n = int(eval(input()))
al = list(map(int, input().split()))
s = sum(al)
ss = 0
m = 10**9+7
d = 500000004
for a in al:
    ss += a*a
print((((s*s-ss)%m*d)%m))
# Original solution
N=int(eval(input()))
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=[]
for i in range(N):
    sum=0
    for j in range(i+1,N):
        sum+=A[j]
    A_sum.append(sum)
    


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

print((S%(pow(10,9)+7)))

# Optimized solution
N=int(eval(input()))
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=0
for i in range(N):
    A_sum+=A[i]
    

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

print((S%(pow(10,9)+7)))
# Original solution
MOD = 10**9+7

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

# print(n, a)

res = 0

for i in range(0, n-1):
    for j in range(i+1, n):
        # print(a[i], a[j], a[i]*a[j])
        res += a[i]*a[j]
   
print((res%MOD))

# Optimized solution
MOD = 10**9+7

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

a1 = sum(a)
a2 = sum([x*x for x in a])

print((((a1**2-a2)//2)%MOD))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)):
    ans += A[i] * sum(A[0:i])
ans = ans % 1000000007
print(ans)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
a_sum = 0
for i in range(len(A)):
    ans += A[i] * a_sum
    a_sum += A[i]
ans = ans % 1000000007
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
sum_A = 0

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

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