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

ans = 1

for i in range(N):
    ans *= A[i]
    if ans>10**18:
        ans = -1
        break
print(ans)

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

def ans():
    global N,A
    for i in range(N):
        if A[i]==0:
            return 0
    tmp = 1
    for i in range(N):
        tmp *= A[i]
        if tmp>10**18:
            return -1
    return tmp

print((ans()))
# Original solution
n = int(eval(input()))
aas = list(map(int, input().split()))
if 0 in aas:
    print((0))
    exit()
res = 1
for i in aas:
    res*=i
if res>10**18:
    print((-1))
else:
    print(res)

# Optimized solution
n = int(eval(input()))
aas = list(map(int, input().split()))
if 0 in aas:
    print((0))
    exit()
res = 1
for i in aas:
    res*=i
    if res > 10 ** 18:
        print((-1))
        exit()
else:
    print(res)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
i=n-1
res=1
z=10**18
while(i>=0):
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
i=n-1
while(i>=0):
    if(a[i]==0):
        res=0
        break
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

s = 1
for i in range(n):
    s *= a[i]

if s > 1000000000000000000:
    print((-1))
else:
    print(s)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
if 0 in a:
    print((0))
else:
    s = 1
    for i in range(n):
        s *= a[i]
        if s > 10**18:
            break
        elif a[i] == 0:
            break
            
    if s > 10**18:
        print((-1))
    else:
        print(s)
# Original solution
x  = int(eval(input()))

line  = [int(y) for y in input().split()]

yeet  = 1

for i in range(0,x):
    yeet = yeet*line[i]

if yeet > 10**18:
    print((-1))
else:
    print(yeet)


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

line  = [int(y) for y in input().split()]
line.sort()

yeet  = 1
solved  = False

if line[0] == 0:
    print((0))
else:
    for i in range(0,x):
        yeet = yeet*line[i]
        if yeet > 10**18:
            solved = True
            print((-1))
            break

    if solved == False:
        print(yeet)
# Original solution
n = eval(input())
s = 1
for i  in input().split():
  s = s * int(i)

if s > 1e+18:
  print((-1))  
else:
  print(s)

# Optimized solution
n = eval(input())
s = 1

int_list = [int(s) for s in input().split()]
if 0 in int_list:
  print((0))
else:
  for i in int_list:
    s = s * int(i)
    if s > 1e+18:
      s = -1
      break
  print(s)
# Original solution
from sys import stdin
N = int(eval(input()))
A = list(map(int, stdin.readline().split()))
"""ans = 1
for a in A:
    ans = ans*a
    if ans == 0:
        break"""
from functools import reduce
ans = reduce(lambda x,y:x*y,A)
if ans >10**18:
    print((-1))
else:
    print(ans)


# Optimized solution
from sys import stdin
N = int(eval(input()))
A = list(map(int, stdin.readline().split()))
if 0 in A:
    print((0))
else:
    ans = 1
    for a in A:
        ans = ans*a
        if ans > 10**18:
            break
    """from functools import reduce
    ans = reduce(lambda x,y:x*y,A)"""
    """import numpy as np
    A = np.array(A)
    ans = np.prod(A)"""
    if ans >10**18:
        print((-1))
    else:
        print(ans)
# Original solution
#TIME : 
import sys
from math import sqrt
input = sys.stdin.readline

def inp():
    return(int(eval(input())))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = eval(input())
    return(list(s[:len(s) - 1]))
def invr():
    return(list(map(int,input().split())))

MAX = 10**18
n = inp()
a = inlt()
if 0 in a:
    print((0))
    exit()
res = 1
for num in a:
    res*=num
if res > MAX:
    print((-1))
else:
    print(res)

# Optimized solution
def main ():
  N = int(eval(input()))
  A = list(map(int,input(). split ()))
  if 0 in A:
      print((0))
      return

  prod = 1
  for a in A:
      prod *= a
      if prod > 1000000000000000000:
          print((-1))
          return
  print(prod)

main ()
# Original solution
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

if 0 in a:
    print((0))
    exit()
now = 1
for i in a:
    now *= i
    if now > 10**18:
        print((-1))
        exit()

print(now)


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

if 0 in a:
    print((0))
    exit()

now = 1

for i in a:
    now *= i
    if now > 10**18:
        print((-1))
        exit()

print(now)
# Original solution
n=int(eval(input()))
a=sorted(list(map(int,input().split())))
ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print((-1))
        break
else:
    print(ans)

# Optimized solution
t=1;[t:=(-1,t:=t*int(a))[0<=t<=1e18] for a in[*open(0)][1].split()];print(t)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 1

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

if ans > 10**18:
    print((-1))
else:
    print(ans)

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

if 0 in a:
    print((0))
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print((-1))
        exit()

print(ans)
# Original solution
#import numpy as np
import functools
import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(eval(input()))
#H1,M1,H2,M2,K= map(int,input().split())
A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
prod = functools.partial(functools.reduce, operator.mul)

#c=np.array(A)
p=prod(A)
if p<0:
    p=p*(-1)

if p>10**18:
    print((-1))
else:
    print(p)


# Optimized solution
N = int(eval(input()))
#H1,M1,H2,M2,K= map(int,input().split())
A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)
c=1
if 0 in A:
    print((0))
    exit()
for i in A:
    c=c*i
    if c>10**18:
        print((-1))
        exit()
print(c)
# Original solution
from operator import mul
from functools import reduce
n = eval(input())
tmp = input().split(" ")
l = (int(e) for e in tmp)
res = 1
res = reduce(mul,l)
if res > 1e+18:
    print("-1")
else:
    print(res)

# Optimized solution
from operator import mul
from functools import reduce
n = eval(input())
tmp = input().split(" ")
l = sorted([int(e) for e in tmp])
def solve():
    res = 1
    for e in l:
        res = e*res
        if res > 1e+18:
            print("-1")
            return
    print(res)
solve()
# Original solution
from functools import reduce 
from operator import mul
N = int(eval(input()))
A = sorted(list(map(int,input().split())),reverse = True)

lim = 10 ** 18
ans = 1

for i in A:
  ans *= i
  if ans > lim and A[-1] > 0:
    ans = -1
    break
    
print(ans)

# Optimized solution
from functools import reduce 
from operator import mul
N = int(eval(input()))
A = sorted(list(map(int,input().split())),reverse = True)

lim = 10 ** 18
ans = 1

if A[-1] == 0:
  print((0))
else:
  for i in A:
    ans *= i
    if ans > lim:
      ans = -1
      break
  print(ans)
# Original solution
N = int(eval(input()))
N_list = [int(i) for i in input().split()]
res = 1
for i in range(len(N_list)) :
    res = res * N_list[i]

if (res > 1000000000000000000) :
    print((-1))
else :
    print(res)

# Optimized solution
def main() :

    N = int(eval(input()))
    N_list = [int(i) for i in input().split()]
    res = 1

    if (N_list.count(0) > 0) :
        print((0))
        return

    for i in range(len(N_list)) :
        res = res * N_list[i]
        if (res > 1000000000000000000) :
            print((-1))
            return
    
    print(res)

main()
# Original solution
eval(input())
*a, = list(map(int, input().split()))
ans = 1
for i in a: ans *= i
print((ans if ans<=10**18 else -1))

# Optimized solution
eval(input())
*a, = list(map(int, input().split()))
if 0 in a:
    print((0))
    exit()
ans = 1
a = sorted(a)[::-1]
for i in a:
    ans *= i
    if ans > 10**18:
        print((-1))
        exit()
print(ans)
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 1
flag = 0
zeroflag = 0
for a in A:
    ans *= a
    if ans > pow(10, 18):
        flag = 1
    if a == 0:
        zeroflag = 1
if flag:
    ans = -1
if zeroflag:
    ans = 0
print((ans if ans <= pow(10, 18) else -1))


# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 1
flag = 0
zeroflag = 0
for a in A:
    if a == 0:
        print((0))
        exit()
for a in A:
    ans *= a
    if ans > pow(10, 18):
        print((-1))
        exit()
print(ans)
# Original solution
import math
import fractions
import collections
import itertools
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
ans=1
flag=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        flag=0
if flag==1:
    print(ans)
else:
    print((-1))

# Optimized solution
import math
import fractions
import collections
import itertools
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
#A=[10**5]*(10**5)
#N=10**5
ans=1
flag=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        flag=0
        break
if flag==1:
    print(ans)
else:
    print((-1))
# Original solution
N = int(eval(input()))
AB = list(map(int, input().split()))

limit = 10 ** 18

sum = 1
for i in range(N):
    sum *= AB[i]

if (limit < sum):
    print((-1))
else:
    print(sum)



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

limit = 1000000000000000000

sum = 1
for i in range(N):
    if (limit < sum or sum == -1):
        sum = -1
    else:
        sum *= AB[i]
    if (AB[i] == 0):
        print((0))
        exit()

if (limit < sum):
    sum = -1

print(sum)
# Original solution
N = int(eval(input()))
nums = input().split()
nums = [int(s) for s in nums]
result = 1
for num in nums:
  result = result * num
if 10**18 < result:
  result = -1
print(result)

# Optimized solution
N = int(eval(input()))
nums = input().split()
end = False
result = 1
for num in nums:
  if num == "0":
    print((0))
    end = True
    break
if not end:
  nums = [int(s) for s in nums]
  for num in nums:
    result = result * num
    if 10**18< result:
      result = -1
      break
  print(result)
# Original solution
n = int(eval(input()))
a = [int(x) for x in input().split()]

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

if ans > 10**18:
    print((-1))
else:
    print(ans)


# Optimized solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
lim = 10**18
flag = True

ans = a[0]

if a.count(0) >= 1:
    ans = 0
else:
    for i in range(1,n):
        ans *= a[i]
        if ans > lim:
            flag = False
            break
            
if flag:
    print(ans)
else:
    print((-1))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

mul = 1
for i in range(N):
    mul *= A[i]

if mul > 10**18:
    print("-1")

else:
    print(mul)


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

#print(A)

A.sort()
#print(A)

mul = 1
for i in range(N):
    if mul == 0:
        break
    elif mul > 10**18:
        mul = -1
        break
    else:
        mul *= A[i]
 
if mul > 10**18:
    print("-1")
else:
    print(mul)
# Original solution
def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))

    res = 1

    for num in A:
        res = res * num
    
    if res > 10 ** 18:
        print((-1))
    else:
        print(res)

if __name__ == '__main__':
    main()

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

    res = 1

    if 0 in A:
        res = 0
    else:
        for num in A:
            res = res * num
            if res > 10**18:
                res = -1
                break
    print(res)

if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
x=list(map(int, input().split()))
 
ans = 1
for i in x:
  ans = ans*i
  
if ans > 1000000000000000000:
  ans = -1
print(ans)


# Optimized solution
n=int(eval(input()))
x=list(map(int, input().split()))
 
ans=1
if 0 in x:
  ans=0
else:
  for i in x:
    ans=ans*i
    if ans>10**18:
      ans=-1
      break
print(ans)
# Original solution
n = int(eval(input()))
a = [int(v) for v in input().split()]
ans = 1
num = 1
limit = 1000000000000000000
for i in a:
    if i == 0:
        num = 0
        break
    if i >= limit:
        num = -1
        break
    else:
        num *= i
if num > limit:
    num = -1
ans = num
print(ans)


# Optimized solution
n = int(eval(input()))
a = [int(v) for v in input().split()]
limit = 1000000000000000000
if 0 in a:
    print((0))
else:
    ans = 1
    num = 1
    for i in a:
        num *= i
        if num > limit:
            num = -1
            break
    ans = num
    print(ans)
# Original solution
while True:
    try:
        for i in range(3):
            line = input().strip()
            if line == '0':
                raise Exception

            a = b = 0
            for i, s in enumerate(line):
                if i != 0:
                    if s == 'A':
                        a += 1
                    else:
                        b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print(a, b)

    except:
        break

# Optimized solution
while True:
    try:
        for i in range(3):
            line = input().strip()
            if line == '0':
                raise Exception

            if line[0] == 'A':
                a = -1
                b = 0
            else:
                a = 0
                b = -1
            for i, s in enumerate(line):
                if s == 'A':
                    a += 1
                else:
                    b += 1
            if a > b:
                a += 1
            else:
                b += 1
            print(a, b)

    except:
        break
# Original solution
# -*- using:utf-8 -*-
from itertools import combinations

if __name__ == "__main__":
  n = int(eval(input()))
  li = list(map(int, input().split()))
  array = list(combinations(li, 2))
  sum = 0
  mod = 1000000007
  for i in range(len(array)):
    sum += array[i][0] * array[i][1]
  ans = sum % mod
  print(ans)

# Optimized solution
# -*- using:utf-8 -*-
from itertools import combinations

class main:
  def v(array):
    sum = 0
    mod = 1000000007
    for i in range(len(array)):
      sum += array[i][0] * array[i][1]
    ans = sum % mod
    print(ans)

if __name__ == "__main__":
  n = int(eval(input()))
  li = list(map(int, input().split()))
  array = list(combinations(li, 2))
  main.v(array)
# Original solution
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

   
    total = 0
    m = int(10**9 + 7)
    for i in range(n-1):
#        for j in range(i+1, n):
#            tmp = (a[i] * a[j]) % m
#            total = (total + tmp) % m
        total = total + (a[i] * (sum(a[i+1:n]) % m))

    total = total % m


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


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

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

   
    total = 0
    m = int(10**9 + 7)
    s = sum(a)
    s_current = 0
    for i in range(n):
        s_current = s_current + a[i]
        total = (total + a[i] * (s - s_current)) % m

    total = total % m


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
# Original solution
import sys

input = sys.stdin.readline


def solve():
    MOD = 10**9+7
    N = int(eval(input()))
    A_L = [int(x) for x in input().split()]
    ans = 0
    for i, ai in enumerate(A_L):
        for j in range(i+1, N):
            aj = A_L[j]
            ans = (ans + ai * aj) % MOD

    print(ans)


solve()


# Optimized solution
import sys

input = sys.stdin.readline


def solve():
    MOD = 10**9+7
    N = int(eval(input()))
    A_L = tuple(int(x) for x in input().split())
    cum_a_l = [0] * N
    cum_a_l[0] = A_L[0]
    for i in range(1, N):
        cum_a_l[i] = (cum_a_l[i-1] + A_L[i]) % MOD
    ans = 0

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


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

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

# 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

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    prefixSums = [0]

    for num in arr:
        prefixSums.append(prefixSums[-1] + num)

    for i, num in enumerate(arr):
        ans = (ans + num * (prefixSums[-1] - prefixSums[i+1])) % MOD

    return ans % MOD


N = readInt()
arr = readList()

print((solve(N, arr)))


# Optimized solution

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    totalSum = sum(arr) % MOD
    currSum = 0

    for num in arr:
        currSum += num
        ans = (ans + num * (totalSum - currSum)) % MOD

    return ans % MOD


N = readInt()
arr = readList()

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

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

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

# 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()))

ans = 0

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

print(ans)

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

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

res = (Asum_sq-ans)//2
print((res%DIV))
# Original solution
n = int(eval(input()))
k = list(map(int, input().split()))

x = 0

for i in range(0, n - 1):
    for j in range(i + 1, n):

        x += (k[i] * k[j]) % (10 ** 9 + 7)

        if x < 10 ** 9 + 7:
            continue
        else:
            x = x % (10 ** 9 + 7)

print(x)

# Optimized solution
mod = 10 ** 9 + 7

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

s = sum(a) 

ans = 0

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

print(ans)
# Original solution
#####
# C #
#####

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

ans = 0
for i in range(len(A)-1):
    tmp1 = A[i] % (10**9 + 7)
    tmp2 = sum(A[i+1:]) % (10**9 + 7)
    ans += tmp1 * tmp2
    ans %= (10**9 + 7)
    # for j in range(1,len(A)-i
    #     # print(A[i],'A[i]',A[i+j],'A[i+j]')
    #     tmp_ai = A[i] % (10**9 + 7)
    #     tmp_aij = A[i+j] % (10**9 + 7)
    #     tmp += (tmp_ai * tmp_aij) % (10**9 + 7)
    #     # print(tmp,'tmp')
    # tmp %= (10**9 + 7)
    # ans += tmp

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

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

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

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

print(sum)

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

mod=10**9+7

B=[0]
for i in range(1,N+1):
    B.append(A[i-1]+B[i-1])

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

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

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

biggest = 0
humidai = 0

result = 0


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

    if result>10**9+7:
        result = result%(10**9+7)

result = result%(10**9+7)

print(result)

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

biggest = 0
humidai = 0

result = 0

tmp_list = []

tmp=sum(A)

for i in range(N-1):

    # for j in range(i+1,N):
        # tmp += A[j]
    tmp -= A[i]
    
    result += A[i]*tmp

    if result>10**9+7:
        result = result%(10**9+7)

result = result%(10**9+7)

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

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

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

MOD = 1000000007
SUM = 0
for i in range(N):
  SUM += A[i]
SUM = SUM*SUM
for i in range(N):
  SUM -= A[i]*A[i]
SUM = SUM // 2
SUM %= MOD
print(SUM)