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

total = 0

for i in range(N):
    #print(i, A[i])
    sum = 0
    start = i + 1
    for j in range(start, N):
        #print(i, j)
        sum = sum + A[j]
    #print(A[i], sum)
    total = (total + A[i] * sum) % 1000000007

print(total)

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

total = 0
left = 0
sum = sum(A)
#print(end)

for i in range(N - 1):
    #print(i, A[i])
    left = left + A[i]
    #start = i + 1
    #for j in range(start, N):
        #print(i, j)
        #sum = sum + A[j]
    #print(A[i], sum)
    right = sum - left
    #print(i, left, right, A[i])
    total = (total + A[i] * right) % 1000000007

print(total)
# Original solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
ans = 0

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

# Optimized solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
sum = 0
ans = 0

for e in a:
  sum += e
  
for e in a:
  sum -= e
  ans += e*sum

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

print(ans)

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

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

print(ans)
# Original solution
import itertools 
N = int(eval(input()))
A = list(map(int,input().split()))
A_comb = list(itertools.combinations(A,2))

tot = 0
for i,j in A_comb:
    cnt = (i*j)%(10**9+7)
    tot = (tot + cnt)%(10**9+7)
    
print(tot)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A_sum = sum(A[1:])

tot = 0
for i in range(N-1):
    tot += (A[i]*A_sum)%(10**9+7)
    tot = tot%(10**9+7)
    A_sum -= A[i+1]
    
print(tot)
# Original solution
import itertools

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


ans = 0

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

print(ans)

# Optimized solution
n = int(eval(input()))
a_list = input().split()

a_list_reverse = a_list[::-1]
# print(a_list_reverse)

rusekiwa = [0] * (len(a_list_reverse) - 1)
sum_v = 0
for i in range(len(a_list_reverse) - 1):
    sum_v += int(a_list_reverse[i])
    rusekiwa[i] = sum_v
# print(rusekiwa)

ans = 0
for i in range(len(a_list) - 1):
    v = int(a_list[i]) * rusekiwa[-1 - (i)]
    # print(v)
    # v = v % (10 ** 9 + 7)
    ans += v
    ans = ans % (10 ** 9 + 7)

# ans = ans % (10 ** 9 + 7)
print(ans)
# Original solution
import itertools
from heapq import heapify, heappop, heappush, heappushpop
nCr = {}






class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap


heap = []  # ヒープといっても順序を工夫したただのリスト

q = PriorityQueue(heap) #ここでインスタンスを作ってます
n = int(eval(input()))
l = list(map(int, input().split()))
mod = 1000000007
result = []
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        result.append([l[i], l[j]])
for a,b in result:
    q.push(((a % mod) * (b % mod)) % mod)
print((sum(heap) % mod))


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

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

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


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

s = sum(a)
aa = [a[i]*a[i] for i in range(n)]
s2 = sum(aa)

print(((s**2 - s2) //2%(10**9+7)))
# Original solution
n = int(eval(input()))
A = list(map(int,input().split()))

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

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

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

sum_a = sum(A)
ans = 0

for i in range(n-1):
	sum_a -= A[i]
	ans += A[i] * sum_a
	ans = ans %(int(1e9 + 7))

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

print(b)


# 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()))
al = list(map(int,input().split()))
sss=0
for i in range(N):
    sss+=al[i]*sum(al[i+1:N])
print((sss%1000000007))

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

print(ans)


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

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

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

ans = 0
b = []
c = 0

for i in range(n-1,0,-1):
    c = c + a[i]
    b.insert(0,c)

b.insert(0,0)

for j in range(n-1):
    ans = (a[j] * b[j+1] + ans) % (10**9+7)

print(ans)


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

ans = 0
b = [0] * n
c = 0

for i in range(n):
    c = c + a[i]
    b[i] = c

for j in range(n-1):
    ans = (a[j] * (b[n-1] - b[j]) + ans) % (10**9+7)

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


# Optimized solution
N=int(eval(input()))
l=list(map(int,input().split()))
b=10**9+7
d=(sum(l))**2
c=0
for i in range(N):
  c=c+l[i]**2
print(((d-c)//2%b))
# Original solution
n=int(eval(input()))
A=list(map(int,input().split()))
MOD = 1000000007
B=0
for i in range(len(A)):
    B += (A[i]*sum(A[i+1:len(A)]))%MOD
print((B%MOD))

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

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

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


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

ans = 0
summ = sum(lst)
summ_sq = summ**2
for i in range(n):
    ans += lst[i]**2

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


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

for i in range(N):
  x = sum(A[i+1:]) % MOD
  y = (A[i] * x) % MOD
  ans += y
  ans %= MOD

print(ans)


# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
MOD = 1000000007
x = sum(A)
ans = 0
 
for i in range(N):
  x -= A[i]
  y = x % MOD
  z = (A[i] * y) % MOD
  ans += z
  ans %= MOD

print(ans)
# Original solution
num = int(eval(input("")))
val = list(map(int,input().split()))
val_sum = 0
mod = 10**9 + 7

for i in range(num):
    for j in range(i+1,num):
        val_sum = val_sum + val[i]*val[j]
        
print((val_sum%mod))

# Optimized solution
num = int(eval(input("")))
val = list(map(int,input().split()))
val_sum = sum(val)
ans = 0
mod = 10**9 + 7

for i in range(num):
    val_sum = val_sum - val[i]
    ans     = val[i] * val_sum + ans
        
print((ans%mod))
# Original solution
N = eval(input())
nums = list(map(int, input().split()))

sum_num = 0
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
        sum_num += nums[i]*nums[j]
        if sum_num > 10**9 + 7:
            sum_num = sum_num%(10**9+7)
print(sum_num)

# Optimized solution
N = eval(input())
nums = list(map(int, input().split()))
rests = []
rest_sum = 0
for i in reversed(nums):
    rest_sum += i
    rests.append(rest_sum)

sum_num = 0
for i in range(len(nums)-1):
    sum_num += nums[i]*rests[-(i+2)]
    if sum_num > 10**9 + 7:
        sum_num = sum_num % (10**9 + 7)
    

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

print(sum)


# Optimized solution
from itertools import accumulate

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(accumulate(a))
sum = 0

for i in range(len(a)):
    sum += a[i]*(b[-1] - b[i])
    sum %= 10**9 + 7

print(sum)
# Original solution
# -*- coding: utf-8 -*-
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    sum = 0
    mod = 1000000007
    for i in range(n-1):
        for j in range(i+1, n):
            sum += a[i]*a[j]
    print((sum%mod))

if __name__ == '__main__':
    main()

# Optimized solution
# -*- coding: utf-8 -*-
from itertools import accumulate
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a_sum = (accumulate(reversed(a)))
    a_sum = list(reversed(list(a_sum)))
    sum = 0
    mod = 1000000007
    for i in range(n-1):
        sum += a[i]*a_sum[i+1]
    print((sum%mod))

if __name__ == '__main__':
    main()
# Original solution
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(A[i+1:])
print((ans%((10**9)+7)))


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

def resolve():
    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=ans%MOD+(A[i]*A[j])%MOD

    print(ans)

resolve()

# Optimized solution
import math
import collections
import itertools

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

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

    print((ans%MOD))

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

ans = 0

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

ans = ans % a
print(ans)

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

ans = 0

for i in range(N):
    sumA -= A[i]
    ans += A[i] * sumA
    ans %= a
    
print(ans)
# Original solution
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:])
  if ans>(10**9+7):
    ans=ans%(10**9+7)
                
print(ans)

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

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


def mod10_9_7(num):
    return num % (10**9+7)


ans = 0
for i in range(N-1):
    for j in range(i, (N)):
        if i != j:
            ii = A[i]
            jj = A[j]
            if ii > 10 ** 5 or jj > 10 ** 5:
                ii = mod10_9_7(ii)
                jj = mod10_9_7(jj)
            ans += ii*jj

print((mod10_9_7(ans)))

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


def mod10_9_7(num):
    return num % (10**9+7)


seki = A[-1]

ans = 0
for i in range(N-2, -1, -1):
    ans += A[i] * seki
    seki += A[i]
print((mod10_9_7(ans)))
# Original solution
def main():
    N = int(eval(input()))
    A_list = list(map(int, input().split()))
    mod = 10**9 + 7

    ans = 0
    for i in range(N):
        A = A_list[i]
        A_ = A_list[i+1:]
        ans = (ans + (A * sum(A_) % mod)) % mod
    print(ans)
    return



if __name__ == '__main__':
    main()
    

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

    ans = 0
    A_ = sum(A_list) % mod
    for i in range(N-1):
        A = A_list[i]
        A_ = A_ - A
        ans = (ans + (A * A_) % mod) % mod
    print(ans)
    return


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

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

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

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

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

sum_value = 0
for i in range(n-1):
    for j in range(i+1,n):
        sum_value += nums[i]*nums[j]

print((sum_value%1000000007))


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

mod = 1000000007


ans = 0
n = A[0]
for a in A[1:]:
    ans += a * n
    n += a

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

# Optimized solution
n=int(eval(input()))
lst=list(map(int,input().strip().split()))
s1=sum(lst)
num=s1*s1
denom=0 
mod=1000000007
for i in range(0,n):
        denom+=(lst[i]*lst[i])
print((((num-denom)//2)%mod))
# Original solution
import itertools

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


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

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

mod = 10**9+7

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

ans = 0
for a, b in zip(A[:-1], sums):
    ans += a * b
    ans = ans % mod

print(ans)
# Original solution
N=int(eval(input()))
An=list(map(int,input().split()))
mod=10**9+7
S=0
for i in range(N):
    for j in range(N):
        if i<j:
            S += An[i]*An[j]
print((S%mod))


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

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

s %= (10**9 + 7)

print(s)


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

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

print(s)
# Original solution
def sekiwa(x):
    n = len(x)
    result = 0
    MOD = 1000000007
    for i in range(n-1):
        for j in range(i+1, n):
            N = nums[i]*nums[j] % MOD
            result += N
            result = result % MOD
    return result

n = int(eval(input()))
nums = list(map(int, input().split()))
print((sekiwa(nums)))

# Optimized solution
MOD = 1000000007
n = int(eval(input()))
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print((((x**2 - y)//2)% MOD))
# Original solution
n=int(eval(input()))
a=list(map(int, input("").split()))
o=0
for i in range(n-1):
    for j in range(i+1,n):
        o+=a[i]*a[j]
        o%=10**9+7
print(o)

# Optimized solution
n=int(eval(input()))
a=list(map(int, input("").split()))
o=0
aa=[]
for i in a:
    aa.append(i**2)
s=sum(a)
o=(s**2-sum(aa))//2
o%=10**9+7
print(o)
# Original solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))

    mod = 10**9 + 7
    answer = 0

    for i in range(0, n-1):
        sum_other = sum(a[i+1:])
        answer += a[i] * sum_other
        if answer >= mod:
            answer %= mod

    print(answer)


'''
    for i in range(n):
        sum_sub = 0
        for j in range(i+1, n):
            sum_sub += a[j]
            if sum_sub >= mod:
                sum_sub %= mod
        answer += a[i] * sum_sub
        if answer >= mod:
            answer %= mod
    print(answer)
'''

'''
    for i in range(n):
        for j in range(i+1, n):
            answer += a[i] * a[j]
            if answer >= mod:
                answer %= mod
    print(answer)
'''

if __name__ == "__main__":
    main()


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

    mod = 10**9 + 7
    answer = 0
    sum_a = sum(a) % mod

    for i in range(n):
        sum_a = sum_a - a[i]
        answer += a[i] * sum_a
        answer %= mod

    print(answer)


'''
    for i in range(n):
        sum_sub = 0
        for j in range(i+1, n):
            sum_sub += a[j]
            if sum_sub >= mod:
                sum_sub %= mod
        answer += a[i] * sum_sub
        if answer >= mod:
            answer %= mod
    print(answer)
'''

'''
    for i in range(n):
        for j in range(i+1, n):
            answer += a[i] * a[j]
            if answer >= mod:
                answer %= mod
    print(answer)
'''

if __name__ == "__main__":
    main()
# Original solution
from itertools import combinations

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

for c in list(combinations(A, 2)):
    tmp = 1
    for e in c:
        tmp *= e
    ans += tmp % (10**9 + 7)

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

# Optimized solution
import sys

input = sys.stdin.readline

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

A_sum_s = sum(A) ** 2

for e in A:
    A_sum_s -= e ** 2
print((A_sum_s // 2 % (10**9 + 7)))
# Original solution
k = int(eval(input()))
num = input().split()

ass = 0

for i in range(k):
    for j in range(i+1,k):
        n1 = int(num[i]) % (10**9 + 7)
        n2 = int(num[j]) % (10**9 + 7)
        n3 = n1 * n2
        ass += n3
        ass = ass % (10**9 + 7)
    ass = ass % (10**9 + 7)


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

# Optimized solution
k = int(eval(input()))
num = input().split()

l = 0
ass = 0
ans = 0

for i in range(k):
    l += int(num[i])

for i in range(k):
    l -= int(num[i])
    ass += int(num[i]) * l
    

ans = ass % (10**9 + 7 )
print(ans)
# Original solution
import sys
input = sys.stdin.readline

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

d = 1000000000 + 7

s = 0
for i in range(N):
    s += A[i] * sum(A[i+1:])
print((s % d))

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

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

d = 1000000000 + 7

s = 0

sum_list = [A[0]]
for a in A[1:]:
    sum_list.append(a + sum_list[-1])
for i in range(N):
    s += A[i] * (sum_list[N-1] - sum_list[i])
print((s % d))
# Original solution
import itertools
N = int(eval(input()))
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

combi = list(itertools.combinations(list(range(N)), 2))

S = 0
for x in combi:
    S = (S + A[x[0]] * A[x[1]]) % mod
print(S)


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

mod = 10 ** 9 + 7

S = 0
for x in range(N):
    for y in range(1, N - x, 1):
        S = (S + A[x] * A[x + y]) % mod

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

mod = 10 ** 9 + 7

S = 0
for x in range(N):
    for y in range(1, N - x, 1):
        S = (S + A[x] * A[x + y]) % mod

print(S)


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

mod = 10 ** 9 + 7

sumA = sum(A)
S = 0

for x in range(N):
    sumA -= A[x]
    S = (S + A[x] * (sumA)) % mod

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

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

print((sum % mod))

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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)
# Original solution
n = int(eval(input()))
Ai = list(map(int, input().split()))
sum_ans = 0
divied_num = 10**9 + 7
for i in range(n-1):
    for j in range(i+1, n):
        sum_ans += Ai[i] * Ai[j]
        sum_ans = sum_ans % divied_num

print(sum_ans)

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

sum_ans = sum(Ai)
ans = 0
mod = 1000000007

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

print(ans)