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:
n = int(input())
lt=input().split(" ")
ans=1
h=1
for i in range(n):
    ans*=int(lt[i])
    if(ans>10**18):
        h=0
        break
if(ans<=10**18 and h==1):
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    for x in A:
        if x==0:
            print(0)
            sys.exit()        
        c=c*x

        if c>10**18:
            print(-1)
            sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
mx=10**18
z=1

a=[int(i) for i in input().split()]
for i in a:
    z*=i
    if z>mx : z=-1
    if z==0 or z==-1 :   break

if z>mx : z=-1
print(z)

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    n = int(input())
    A = np.array(list(map(int, input().split())))
    limit = 10 ** 18
    if np.any(A==0):
        print(0)
    else:
        ans = 1
        for i in range(n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        if ans > limit:
            print(-1)
        else:
            print(ans)


if __name__ == "__main__":
    main()

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:
        ANS = -1
        break

print(ANS)

Submission status: Wrong Answer

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

if 0 in A:
    ans = 0
else:
    for num in A:
        ans *= num
        if ans > 1e18:
            ans = -1
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
   if mt.log10(ans) <8:
      print(ans)
   else:
    print(-1)
else:
  print(0)

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)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input().split())
ans=1
f=0
for i in a:
    ans=ans*int(i)
    if ans>1000000000000000000:
        f=1
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans = A[0]
MOD = 10**6
cnt = 0
for i in range(1,n):
    ans = ans * A[i]
    tmp = ans // MOD
    if tmp != 0:
        ans = ans % MOD
        cnt += tmp
    if cnt >= 3:
        ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input()); s= 1
lis = list(map(int,input().split()))
if 0 in lis: print(0)
else:
    for i in range(n):
        s = s*lis[i]
    s = str(s)
    if len(s)>18: 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>1:
    print(-1)
       
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

t = 1

for i in range(n):
    if a[i] == 0:
        print("0")
        exit()

for i in range(n):
    if t > 10**18:
        print("-1")
        exit()

    t = t * a[i]

print(t)

Submission status: Wrong Answer

Solution code:
def f():
    n = int(input())
    x = int(1e18)
    arr = list(map(int, input().split(' ')))
    ans = 1
    for i in arr:
        ans = ans * i
        if ans > x:
            print(-1)
            return
    print(ans)
f()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    if 0 in b:
        ans = 0
    else:
        for i in range(len(b)):
            ans *= i
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)

Submission status: Wrong Answer

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

res = 1
flg = True
for i in arr:
    res*=i
    if res >=10**18:
        print(-1)
        flg = False
        break
if flg: print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int,input().split()))
#A = np.sort(np.array(A))
A = np.array(A)

ans = np.prod(A)
if ans > 10**8:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 1

s = 0

for i in A:
    ans *= i
    if ans > 10 :
        t = ans // 10
        s += t
        ans %= 10
if s >= 18:
    print(-1)
else:
    print(ans * (10 **s))

Submission status: Wrong Answer

Solution code:
n=input()
a=input().split()
a=[int(i) for i in a]
ans=1
c=True
for i in a:
  ans*=i
  if (ans>1000000000000000000):
    print(-1)
    c=False
if (c):
  print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
if a == 2:
    abox = 1000000000 * 1000000000
    print(abox)
elif a == 3:
    abox = 101 * 9901 * 999999000001
    print(-1)
elif a == 31:
    abox = 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
    print(abox)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
v = []
v = [int(x) for x in input().split()]
for x in v:
	ans = ans*x
	if ans > 1e18:
		break
if ans > 1e18:
	print(-1)
else :
	print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

print(ans)

Submission status: Wrong Answer

Solution code:
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)
        break

if m<=10**18:
    print(m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

N = int(input())
A_array = np.array(list(map(int, input().split())))
ans = A_array.prod()
print(-1 if ans > 10 ** 18 else ans)

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 ans>10**18:
        break
if ans>10**18:
    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 range(0, len(a)):
    ans = ans*int(a[i])

if ans > 100000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
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()
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
input_int = [*map(int, input().split(" "))]
result = int(np.prod(input_int))
print(result if result <= 1e+18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
flag = 1
total = 1
alist = list(map(int, input().split()))
for i in range(n):
  a = alist[i]
  total *= a
  if total >= 10**18:
    flag = 0
    break

if flag:
  print(total)
else:
  print("-1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for a in A:
    if(a==0):
        print(0)
        sys.exit()

ans = 1
for a in A:
    ans *= a
    if(ans >= 1000000000000000000) :
        print(-1)
        sys.exit()
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")
        exit()
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())

a=[]

import sys

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


c=int(a[0])

for k in range(1,n):

    c*=int(a[k])

    if c>10**18:
        print(-1)
        sys.exit()


print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a_list = np.array(list(map(int, input().split())))

ans = np.prod(a_list)

if ans > pow(10,18):
              print("-1")
else:
              print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


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

max = 10 ** 18

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

result = np.prod(A)

if result > max:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
print(A)
re = reduce((lambda x, y: x * y), A)
if re <= 10**18: 
    print(re)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
  if prod >= 10 ** 18:
    print(-1)
  else:
    print(prod)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a = [int(i) for i in input().split() if i!="1"]

if 0 in a:
    print(0)

ans=1
for aa in a:
    ans=ans*aa
    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 a in A:
  ans *= a
  if ans > 10**18:
    ans = -1
    break
  if ans == 0:
    break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

p = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np

input()
A = list(map(int, input().split()))
k=np.prod(A)
if k > 10**(18):
  print(-1)
else:
  print(k)

Submission status: Wrong Answer

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

result = 1

for num in nums:
    result *= num

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

Submission status: Wrong Answer

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

def main(ar):
    ans = 1
    for i in ar:
        if ans > 10**18:
            return -1
        ans *= i
    return ans
ans = main(ar)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
a = np.array(a_list)
total = a.prod()
if total >= 10**18:
    print(-1)
else:
    print(int(total))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)

ans = a.prod()

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

Submission status: Wrong Answer

Solution code:
input()
l = map(int, input().split())
r = 1
if 0 in l:
    print(0)
else:
    for i in l:
        r *= i
        if r > 1e18:
            break
    print(-1 if r > 1e18 else r)

Submission status: Wrong Answer

Solution code:
# ABC169 B Multiplication 2

from collections import deque

n = int(input())

a_list = deque([int(x) for x in input().split()])

ans = 1
for i in range(n):
    ans *= a_list.popleft()
    if ans > 10**18:
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = input().split()
total = 1
for i in range(len(A)):
	total *= int(A[i])
if (total > 10**18):
	print(-1)
else:
	print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())
num = 1
for i in a:
  num = num*i
  if num >= 10**18:
    print(-1)
    exit()
  elif num == 0:
    print(0)
    exit()
print(num)

Submission status: Wrong Answer

Solution code:
import sys
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)
    sys.exit(0)

print(ans)

Submission status: Wrong Answer

Solution code:
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    for i in A:
        if times < 10**18: 
            times *= i
    if times > 10**18:
        print(-1)
    else:
        print(times)
m()

Submission status: Wrong Answer

Solution code:
def default():
    maxi=1000000000000000000
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    flag=0
    for i in range(0,n):
        temp[i]=int(temp[i])
        answer*=temp[i]
        if(answer>maxi):
            flag=1
            break
        if(temp[i]==0):
            flag==2
            break
    if(flag==1):
        print(-1)
    else:
        if(flag==2):
            print(0)
        else:
            print(answer)

if(__name__=="__main__"):
    default()

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(map(int, input().split()))
INF = 10 ** 18
ans = 1
for num in arr:
    if ans > INF:
        ans = -1
        break
    elif ans == 0:
        break

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 = ans * A[i]

if ans >= 1e+19:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit
from numpy import prod


def main():
    input = stdin.buffer.readline
    n = int(input())
    ans = prod(list(map(int, input().split())))
    if ans > 10 ** 18:
        print(-1)
        exit()
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

##### 進数の変換 #####
# bin_str = bin(i)[2:]
# oct_str = oct(i)[2:]
# hex_str = hex(i)[2:]

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	ans = 0
	for i,vol in enumerate(A):
		if i == 0:
			ans = vol
			continue
		ans = ans * vol
		if ans > 1000000000000000000:
			print(-1)
			sys.exit()

	print(ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索のリバース
def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# 2分検索
# 存在しない場合: None 存在する場合: その値
def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# N 個のボールを K グループに分ける場合のパターン数
def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
n = int(input())
num = [int(x) for x in input().split()]

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

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    n = int(input())
    a_list = map(int, input().split())

    result = 1

    for a in a_list:
        result *= a
        if result > 10**18:
            print('-1')
            return

    print(result)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 1
for ll in l:
  ans *= ll
  if ans > 10**18:
    break
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


for i in range(N):
  if (i == 0):
    ans = a[0]
  else:
    ans = ans * a[i]
    if (ans > 10**18):
      print('-1')
    else:
      print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())

ans=1
for a in A:
    if a==0:
        ans*=a
    elif ans==-1:
        pass
    else:
        ans*=a
        if 10**18<ans:
            ans=-1