Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = list(map(int,input().split()))
INF = 10 ** 18
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > INF:
        print(-1)
        sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
K = [int(i) for i in input().split()]

ans = 1
for k in K:
    ans *= k
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
m=1
for i in range(n):
  m*=a[i]
  if m>10**18:
    print(-1)
    sys.exit()
print(m)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=1
for i in A:
  ans*=i
  if ans>=10**18:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())

"""========main code==============="""
t=ii()

a=ll()
s=1
f=0
for i in a:
    s*=i
    if(s>10**18):
        f=1
        break
if f:
    print(-1)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

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

Submission status: Wrong Answer

Solution code:
x=int(input())
s=list(map(int,input().split()))
res=1
for n in s:
	res*=n
	if res>1e18:
		print(-1)
		exit(0)

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
if(ans > 10**8):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ret = 1
    for a in A:
        ret *= a
        if ret > 10**18:
            ret = -1
            break
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
ans = 1
for i in s:ans*=i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
LI = lambda: list(map(int, input().split()))

n =int(input())
a = LI()
prod = 1
for x in a:
    prod *= x
    if prod > 10**18:
        print(-1)
        break
else:
    print(prod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for x in a:
    ans *= x
    if ans >= 10 ** 18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N=input()
    A = list(map(int, input().split()))
    ans=1
    for i in A:
        ans*=i
        if ans>10**18:
            print(-1)
            return 
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd, sqrt, cos, radians, pi
from collections import defaultdict as d
from itertools import combinations as c

n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
arr = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
ans = 1
for i in range(N):
    ans *= A[i]
    if (ans >= 10 ** 18):
        print(-1)
        exit()
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

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

else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

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

print(ans if ans < 1000000000000000000 else -1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
    res*=a[i]
    if res>10**18:
        print(-1)
        break
else:
    print(res)

Submission status: Wrong Answer

Solution code:
ans=1
n=int(input())
lim=10**18
for i in list(map(int,input().split())):
    ans*=i
    if ans>lim:print(-1);exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**8 or s< 0:
    flg = True
    break
if flg:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
res = 1
for a in map(int, input().split()):
  res *= a
  if res > 10 ** 18:
    print(-1)
    break
else:
  print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
ans = 1
for num in S:
    ans *= num
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = 1
for x in a:
  res *= x
  if res > 10 ** 18:
    print(-1)
    exit(0)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(num) for num in input().split()]
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ans = -1
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

res = 1
for a in A:
    res *= a
    if res > pow(10, 18):
        print(-1)
        exit()
print(res)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
now = 1
for i in a:
    now *= i
    if now > 10**18:
        print(-1)
        exit()

print(now)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

a = list( map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    if ans >10**18:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int,input().split()))
ans = 1
f = 0
for i in arr:
    ans = ans*i
    if ans>10**18:
        f = 1
        break
if f==1:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in l:
    ans *= i
    if ans > 10 ** 18: 
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=1 
for x in l:
  ans=ans*x
  if ans>10**18:
    print(-1)
    quit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
for x in a:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int,input().split()))

ans=1
INF = pow(10,18)
for l in L:
    ans*=l
    if ans>INF:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int()
a = list(map(int, input().split()))
s = 1
for i in a:
    s*= i
if s > pow(10, 18):
    print(-1)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
sum = 1
a = list(map(int, input().split()))
for i in range(n):
  sum = sum*a[i]
  
if sum > 1e10:
  print(-1)
else:
  print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= arr[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = 1
for a in input().split():
    a = int(a)
    s *= a
    if s > 10 ** 18:
        print(-1)
        break
else:
    print(s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
from queue import PriorityQueue
import itertools
from copy import deepcopy
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):
    if b:print("yes")
    else:print("no")
def Yn(b):
    if b:print("Yes")
    else:print("No")
def YN(b):
    if b:print("YES")
    else:print("NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(bbool,ret1,ret2):
    if bbool:return ret1
    else:return  ret2
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def pm(x):
    return x//abs(x)
def inputintlist(): 
    return list(map(int,input().split()))
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def ruisekiwa(A):
    ret=[0]*(len(A)+1)
    for a in range(len(A)):
        ret[a+1]=ret[a]+A[a]
    return ret
def getmd(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow









######################################################################################################
n=int(input())
A=inputintlist()
ans=1
for a in A:
    ans*=a
if a>10**10:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
  ans *= i
  if ans > 10 ** 18:
    print(-1)
    break
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
b = 10**18
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
  if ans > b:
    ans = -1
    break
print(ans)

Submission status: Wrong Answer

Solution code:
# 0や1のケースに注意
# index out of range
# 貪欲

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 1
    for i in a:
        res *= i
        if res == 0:
            print(0)
            break
        if res > 10**18:
            print(-1)
            break
    else:
        print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
mod = 10**18
r = 1
for i in a:
    r *= i
    if r > mod:
        print(-1)
        import sys
        sys.exit()
print(r)

Submission status: Wrong Answer

Solution code:

from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
#n,m=input_list()
a=input_list()
ans=1
for i in a:
    ans*=i

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

else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
ans = 1
for a in A:
    ans *= a
    if ans > 10**18: ans = -1; break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
M = 10**18
ans = 1
for a in A:
  ans *= a
  if ans > M:
    print(-1)
    quit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
aaa = list(map(int, input().split()))
INF = 10 ** 18
ans = 1
for a in aaa:
    ans *= a
    if ans > INF:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))
 
def main():
    n=I()
    a=L()
    ans=1
    for i in a:
        ans*=i
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
ans=1
for val in arr:
  ans*=val
  if ans>10**18:
    print(-1)
    break
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    i = 1
    for a in A:
        i *= a
        if i > 10 ** 18:
            return -1

    return i

print(main())
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(map(int,input().split()))
k=10**18
m=1
for i in range(n):
    m *= l[i]
    if l[i]==0:
        print('0')
        exit()
if m>k:
    print('-1')
else:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
sum_=1
for i in range(N):
    while sum_ < 10**18:
        sum_ *= a[i]
        if sum_ > 10**18:
            sum_ =-1
        break
print(sum_)

Submission status: Time Limit Exceeded

Solution code:
n = int(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)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

for i in range(n):
    ans*=A[i]
if ans>1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

ans=int(1)

for i in range(n):
    ans*=A[i]
if ans>1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

product = 1
for num in A:
    product = product * num
    if product > 10 ** 18:
        product = -1
    if 0 in A:
        product = 0

print(product)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
mod = 10**18
li = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = ans * li[i]
if ans > mod:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = ans * li[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

res = 1
for i in range(n):
    res *= a[i]
    if res == 0:
        break

if res > 10**18:
    res = -1

print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
product = 1
for a in a_list:
    product *= a
if product > 10**18:
    print(-1)
else:
    print(product)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
a = list(map(int,input().split()))
score=1
for i in a:
  score*=i
if score>10**18:
  print(-1)
  exit()
print(score)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
a = list(map(int,input().split()))
score=1
for i in a:
  score*=i
if score>1e18:
  score=-1
print(score)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i
print(-1 if ans > pow(10, 18) else ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
score=1
a=input().split()
for i in a:
  score*=int(i)
if score>1e18:
  score=-1
print(score)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
score=1
for i in range(n):
  score*=a[i]
if score>10**18:
  print("-1")
else:
  print(score)

Submission status: Time Limit Exceeded

Solution code:
input();ans,limit=1,10**18
for i in map(int,input().split()):
  ans*=i
print([ans,-1][ans>limit])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aa = list(map(int, input().split()))

if 0 in aa:
    print("0")
else:
    result = 1
    for a in aa:
        result *= a

    if result > pow(10, 18):
        result = -1

    print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aa = list(map(int, input().split()))

result = 1
for a in aa:
    result *= a

if result > pow(10, 18):
    result = -1

print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int ,input().split()))
a.sort()
myans=1
for i in range(0,n):
    myans*=a[i]
if(myans>10**18 ):
    print(-1)
elif(myans<10**18 or myans==10**18):
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int ,input().split()))
myans=1
for i in range(0,n):
    myans*=a[i]
if(myans>10**18 ):
    print(-1)
elif(myans<10**18 or myans==10**18):
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int ,input().split()))
myans=1
for i in range(0,n):
    myans*=a[i]
if(myans>10**18):
    print(-1)
else:
    print(myans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
cnt=0
while cnt<n:
  if a[cnt]==0:
    print(0)
    exit()
  ans*=a[cnt]
  cnt+=1
if ans>10**18:
  print(-1)
  exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
  ans*=a[i]
if ans>10**18:
  print(-1)
  exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans=1
for i in a:
    ans*=i
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
input();l=input().split();x=1
for j in sorted(l):x*=int(j);
if x>1e18:x=-1
print(x)

Submission status: Time Limit Exceeded

Solution code:
a,b=open(0);c=1;
for i in b.split():c=[d:=int(i)*c,-1][10**18<d or d*c<0]
print(c)

Submission status: Time Limit Exceeded

Solution code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:x*=int(j);
if x>1e18:x=-1
print(x)

Submission status: Time Limit Exceeded

Solution code:
a,b=open(0);c=1;
for i in b.split():c*=int(i)
if c>10**18:print(-1);exit()
print(c)

Submission status: Time Limit Exceeded

Solution code:
input()
a=1
for i in input().split():
  a*=int(i)
print([a,-1][a>1000000000000000000])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
s =list(map(int,input().split()))
mod = 10 **18
ans = 1
if 0 in s:
    print(0)
    exit()
for i in s:
    ans = ans *i
if ans > 1e18:
    print(-1)
    exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import operator
import functools
mod = 10**18
a = int(input())
s = list(map(int,input().split()))
result = functools.reduce(operator.mul,s)
if result > (mod):
    print(-1)
    exit()
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
import operator
import functools
a = int(input())
s = list(map(int,input().split()))
result = functools.reduce(operator.mul,s)
if result > (10**18):
    print(-1)
    exit()
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
s = list(map(int,input().split()))
num = 1
for i in range(a):
    num *=s[i]
    if s[i] ==0:
      print(0)
      exit()    
if num > (10**18):
    print(-1)
    exit()
else:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
s = list(map(int,input().split()))
num = 1
for i in range(a):
    num *=s[i]
    
if num > (10**18):
    print(-1)
    exit()
else:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = 1
for e in a:
  x *= e
if x > 10**18:
  print(-1)
else:
  print(x)

Submission status: Time Limit Exceeded

Solution code:
def check() -> int:
    n = int(input())
    n_l = list(map(int, input().split()))

    VORDER = 10 ** 18
    ans = 1

    for i in n_l:
        if 0 in n_l:
            ans = 0
            break
        ans = i * ans
        if ans > VORDER:
            ans = -1
            break

    return ans


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

Submission status: Time Limit Exceeded

Solution code:
def check() -> int:
    n = int(input())
    n_l = list(map(int, input().split()))

    VORDER = 10 ** 18
    ans = n_l[0]

    for i in range(1, n):
        if 0 in n_l:
            ans = 0
            break
        ans = n_l[i] * ans
        if ans > VORDER:
            ans = -1
            break

    return ans


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

acc = 1
for i in input().split():
  acc *= int(i)

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

N = int(input())
AS = [int(i) for i in input().split()]

m = reduce(mul, AS, 1)
if m > 10**18:
  print('-1')
else:
  print(m)

Submission status: Time Limit Exceeded

Solution code:
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    li_A = list(map(int, input().split()))

    ans = li_A[0]

    for i in range(1,N):
        if (ans * li_A[i]) <= 1000000000000000000:
            ans = ans * li_A[i]

        else:
            ans = -1

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
prod=1
for i in a:
    prod*=i
if prod>10**18:
    print(-1)
else:
    print(prod)