CodeEff/ECCO huggingface dataset:
# Original solution
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


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



# Optimized solution
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


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

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

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

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

MOD = 10 ** 9 + 7
S = 0
for c in list(itertools.combinations(As, 2)):
    S += c[0] * c[1] % MOD
print((S % MOD))

# Optimized solution
# import itertools

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

MOD = 10 ** 9 + 7
S = 0
# for c in list(itertools.combinations(As, 2)):
#     S += c[0] * c[1] % MOD
for i in range(N):
    for k in range(i+1, N):
        S += As[i] * As[k] % MOD
print((S % MOD))
# Original solution
n = int(eval(input()))
l = list(map(int,input().split())) 
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans += l[i]*l[j]
        
print((ans%(10**9 + 7)))

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

totalsqr = (sum(l))**2

individualsqrsum=0
for i in l:
    individualsqrsum += i**2

ans = (totalsqr  - individualsqrsum)  // 2 
ans = ans%(10**9 + 7)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
MOD = 10**9 + 7
kake = 0

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

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

for i in range(N-1):
    B[N-i-1] = A[N-i-1]+B[N-i]
ans = 0
MOD = 10**9 + 7

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

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


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

# Optimized solution
import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(eval(input()))
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum = (sum+ A[i]*A[j])%(10**9+7)
print(sum)

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

# Optimized solution
N = int(eval(input()))
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation1 = sum(B) ** 2
summation2 = sum(b ** 2 for b in B)
summation = ((summation1 - summation2) // 2) % x
print(summation)
# Original solution
MOD = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
ans, rem = 0, 0
for i in range(n - 1):
    rem += a[n - 1 - i] % MOD
    ans += a[n - 2 - i] * rem % MOD
print((ans % MOD))

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

m = 1000000007

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

result = 0
b = list(accumulate(A))
for i in range(N):
    result += A[i] * (b[N - 1] - b[i])
    result %= m
print(result)


# Optimized solution
m = 1000000007

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

result = 0
a = 0
for i in range(1, N + 1):
    result += a * A[N - i]
    a += A[N - i]
    result %= m
print(result)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
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
su = 0
a = 0

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

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

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

B = list([x ** 2 for x in A])

SA = sum(A)
SB = sum(B)

print((((SA * SA - SB) // 2) % mod))
# Original solution
mod = 1000000007
n = int(eval(input()))
a = list(map(int,input().split()))
import itertools
b = list(itertools.combinations(a, 2))
#print(b)
for i in range(len(b)):
    b[i] = (b[i][0]*b[i][1])%mod
print((sum(b)%mod))

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

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

result = 0
for i in range(n):
    x = a[i]
    if abs(x-m) < x:
        x -= m
    y = 0
    for j in range(i+1, n):
        y = (y + a[j]) % m
    result = (result + (x*y)) % m

if(result < 0):
    result += m
print(result)

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

result = 0

sum_a = 0
for i in range(n):
    sum_a = (sum_a + a[i]) % m

result = 0
for i in range(n):
    x = a[i]
    sum_a -= x
    result = (result + x*sum_a) % m

if(result < 0):
    result += m
print(result)
# Original solution
import itertools
k = 10 ** 9 + 7
N = int(eval(input()))
L = list(map(int, input().split()))
S = 0
for c in itertools.combinations(L, 2):
  S += (c[0] * c[1]) % k
print((S % k))

# Optimized solution
k = 10 ** 9 + 7
N = int(eval(input()))
L = list(map(int, input().split()))
S = sum(L) ** 2
for i in L:
  S -= i ** 2

print(( (S // 2) % k))
# 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]
print((ans%mod))


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

s = sum(A)

for a in A:
    s -= a
    ans += a * s

print((ans%mod))
# Original solution
#abc177_C_5_あまりの計算を挟むのは、その計算の対象になるときだけ
int_n = int(eval(input()))
list_tmp = list(map(int, input().split()))

int_sum = 0
int_divide = (10**9) + 7
 
for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    if list_tmp[i] >= int_divide:
      list_tmp_i = list_tmp[i]%int_divide
    else:
      list_tmp_i = list_tmp[i]
      
    if list_tmp[j] >= int_divide:
      list_tmp_j = list_tmp[j]%int_divide
    else:
      list_tmp_j = list_tmp[j]    
    
    int_sum = int_sum + (list_tmp_i*list_tmp_j)
    
    if int_sum >= int_divide:
      int_sum = int_sum%int_divide
      
print(int_sum)
    


# Optimized solution
#abc177_C_6_retry_累積和を使用する
int_n = int(eval(input()))
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
int_sum_tmp = sum(list_tmp)

for i in range(0, len(list_tmp) - 1):
  int_sum_tmp = int_sum_tmp - list_tmp[i]
  int_sum = int_sum + (int_sum_tmp * list_tmp[i])
print((int_sum % int_divide))
#  for j in range(i + 1, len(list_tmp)):
#    if list_tmp[i] >= int_divide:
#      list_tmp_i = list_tmp[i]%int_divide
#    else:
#      list_tmp_i = list_tmp[i]
#      
#    if list_tmp[j] >= int_divide:
#      list_tmp_j = list_tmp[j]%int_divide
#    else:
#      list_tmp_j = list_tmp[j]    
#    
#    int_sum = int_sum + (list_tmp_i*list_tmp_j)
#    
#    if int_sum >= int_divide:
#      int_sum = int_sum%int_divide
#      
#print(int_sum)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

mod = 1000000007

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

print(ans)


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

mod = 1000000007
s = sum(a) % mod
ans = 0

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

print(ans)
# Original solution
def main():
    n = int(eval(input()))
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    sum_a = sum(a_list)
    ans = 0

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

    print((ans % mod))


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    x = 0
    ans = 0

    for i in range(1, n):
        x = (x + a_list[i - 1]) % mod
        ans = (ans + a_list[i] * x) % mod

    print(ans)


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

max = (10 ** 9) + 7

sum = 0
for i in range (n-1):
    for j in range (n):
        if i > j:
            continue
        if i != j:
            sum += a[i]*a[j]
        if sum > max:
            sum = sum % max


print(sum)


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

max = (10 ** 9) + 7

#一列の総和
wa = 0
for i in range (n):
    wa += a[i]

#a11, a22, ...の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((wa*wa) - rem) // 2

ans = sum % max

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

max = (10 ** 9) + 7

#一列の総和
wa = 0
for i in range (n):
    wa += a[i]

#a11, a22, ...の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((wa*wa) - rem) // 2

ans = sum % max

print(ans)

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

max = (10 ** 9) + 7

#入力配列の総和
line = 0
for i in range (n):
    line += a[i]

#a11, a22, ...対角線要素の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((line*line) - rem) // 2

ans = sum % max

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


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

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

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

ans=0
total=0

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


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

ans=0
total=0
t=sum(x)

for i in range(n):
 
  t=t-x[i]
  total=total+x[i]*(t)
  
   
    
print((total %1000000007))
# Original solution
def resolve():
    n = int(eval(input()))
    a = list(map(int, input().split()))

    ans = 0
    num = (10 ** 9) + 7

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

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

    ans = 0
    mod = (10 ** 9) + 7
    csum = sum(a)

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

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

def Calc(a: int, b: int) -> int:
    return (a * b) % m

ans = 0

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

print(ans)


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

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

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

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

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


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

for i in range(n-1):
  for j in range(i+1,n):
    total += L[i]*L[j]
print((total % (10**9+7)))

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

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

print(sum)

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

MOD = 10**9 + 7
sum_A = 0
for i in range(N):
    sum_A = (sum_A + A[i]) % MOD

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


print(sum)
# Original solution
N = int(eval(input()))
As = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(N-i-1):
        ans += As[i]*As[j+i+1]
        if ans >= 10**9+7:
            ans = ans%(10**9+7)

print(ans)


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

sum = 0
for i in range(N):
    sum += As[i]
    sum %= 10**9+7

ans = 0
for i in range(N):
    sum -= As[i]
    ans += As[i]*sum
    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):
  for j in range(i+1,n):
    ans=(ans+a[i]*a[j])%(10**9+7)
print(ans)

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

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print((wa % (10**9+7)))
# Original solution
import sys
input = sys.stdin.readline

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

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
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]
        if ans>10**9+7:
            ans%=10**9+7
print(ans)

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

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

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
n=int(eval(input()))
a=list(map(int, input().split()))
ans=0
anss=[0]*(n+1)
for i in range(1,n+1):
    anss[-i-1]=anss[-i]+a[-i]
    if anss[-i-1]>10**9+7:
        anss[-i-1]%=10**9+7
#print(anss)
for i in range(n-1):
    ans+=a[i]*anss[i+1]
    if ans>10**9+7:
        ans%=10**9+7
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7

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


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

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

# Optimized solution
n=int(eval(input()))
lst=list(map(int,input().split()))
total=0
temp=0
for i in range(1, n):
  temp+=lst[i]
for j in range(n-1):
  total+=lst[j]*temp
  temp-=lst[j+1]
print((total%(10**9+7)))
# Original solution
def s():return int(eval(input()))
def mp():return list(map(int,input().split()))
# a =s()
# b =s()
# ans = ""
# for i in range(len(b)):
# 	ans+=b[i]
# 	if ans in a:
# 		pass
# 	else:
# 		print(len(b)-i)
# 		break

a = s()
b = list(mp())
ans=0
for i in range(a):
	for j in range(i+1,a):
		ans+=b[i]*b[j]
		ans%=((10**9)+7)
print(ans)

# Optimized solution
def s():return int(eval(input()))
def mp():return list(map(int,input().split()))
a = s()
b = list(mp())
ans=0
t = sum(b)%(10**9+7)
for i in range(a):
	t-=b[i]
	ans+=b[i]*t
	ans%=(10**9+7)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
pro = []
for i in range(N-1):
    redi = 0
    for j in range(i+1,N):
        redi += (A[i] * A[j])%(1000000007)
    pro.append(redi)
red = sum(pro)
res = red%(1000000007)
print(res)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
sumA = sum(A)%(1000000007)
sumA2 = (sumA * sumA)%(1000000007)
square = 0
for i in range(N):
    square +=  ( A[i]**2 ) % (1000000007)
    square = square % (1000000007)
buf = sumA2 - square
if buf < 0:
  buf = buf + (1000000007)
res = ( buf * ((1000000007+1)//2)) % 1000000007
print((int(res)))
# Original solution
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))

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

    print(sum)


if __name__ == "__main__":
    main()


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

    B = sum(A)
    answer = 0
    for i in range(0, N):
        answer += A[i] * (B - A[i])
        B -= A[i]

    answer %= (10 ** 9 + 7)

    print(answer)


if __name__ == "__main__":
    main()

# A1*A2 + A1*A3 + ... + A1*AN = A1 * (A2 + A3 + ... + AN)
# +
# A2*A3 + A2*A4 + ... +| A2*AN = A2 * (A3 + A4 + ... + AN)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    ans += (a[i]*sum(a[i+1:]))
    ans = ans % (10**9+7)
print(ans)

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

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

ans = ans % 1000000007
print(ans)

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

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

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

mod = 10**9 + 7
ans = 0

for x in range(m-1):
  if a[x] % mod != 0:
    tmp = sum(a[x+1:m])
    ans += a[x] * tmp

print((ans%mod))

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

mod = 10**9 + 7
ans = 0

tmp_sum = sum(a[1:m]) % mod

for x in range(m-1):
  if a[x] % mod != 0:
    ans += (a[x] * tmp_sum) % mod
  
  tmp_sum -= a[x+1] % mod

print((ans%mod))
# Original solution
def resolve():
    n = int(eval(input()))
    a = tuple(map(int,input().split()))
    N = 10**9+7
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            ans += a[i]*a[j]
            ans %= N
    print(ans)
resolve()

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

s = 0
m=10**9+7
for i in range(n-1):
    ss=0
    for j in range(i+1,n):
        ss+=a[j]
    ss=ss%m
    s+=(a[i]*ss)%m


print((s%m))



# Optimized solution

n = int(eval(input()))
mod = 1000000007
a = list(map(int,input().split()))
width = 0
ans = 0
for i in range(n):
    ans = (ans + a[i]*width)  % mod
    width = (width + a[i]) % mod

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

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

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

big = pow(10,9) + 7
sums = pow(sum(a),2)
a_2 = list([x ** 2 for x in a])

print((((sums-sum(a_2)) // 2)%big))