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())
A = list(map(int, input().split()))
result = 1
for i in A:
    result *= i
    if result > 10 ** 18:
        print(-1)

print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

def main():
    N = getVar()
    A = getArray()

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

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

def main():
    N = getVar()
    A = getArray()

    m = 1

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

    print(m)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print('-1')
            return

    print(str(m))

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

N = getVar()
A = getArray()

m = 1
upper = 1000000000000000000

if 0 in A:
    print(0)
else:
    for a in A:
        m *= a
        if m > upper:
            break

    if m > upper:
        print('-1')
    else:
        print(str(m))

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

N = getVar()
A = getArray()

m = np.multiply.reduce(A)
upper = pow(10, 18)

if m > upper:
    print('-1')
else:
    print(str(m))

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

N = getVar()
A = getArray()

m = 1
upper = pow(10, 18)
if 0 in A:
    print(0)
else:
    for a in A:
        m *= a
        if m > upper:
            break

    if m > upper:
        print('-1')
    else:
        print(str(m))

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

N = getVar()
A = getArray()

m = 1
upper = pow(10, 18)
if 0 in A:
    print(0)
else:
    for a in A:
        m *= a
        print(m)
        if m > upper:
            break

    if m > upper:
        print('-1')
    else:
        print(str(m))

Submission status: Wrong Answer

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

N = getVar()
A = getArray()

m = 1
upper = pow(10, 18)
for a in A:
    m *= a
    if m >= upper:
        break

if m >= upper:
    print('-1')
else:
    print(str(m))

Submission status: Wrong Answer

Solution code:
N = input()
M = list(map(int,input().split()))
    
mult = 1
    
for a in M:
    mult *= a
    if mult> 1000000000000000000:
        print(-1)
        
print(mult)

Submission status: Wrong Answer

Solution code:
N = input()
M = list(map(int,input().split()))
    
mult = 1
    
for a in M:
    mult *= a
    if mult>1000000000000000000:
        print(-1)
        
print(mult)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N =input()
A  =input().split()
ans =1
for i in range(int(N)):
  ans *= int(A[i])
  if(ans > int(1e18)):
    print(-1)
    sys.exit()
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i

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

Submission status: Wrong Answer

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

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i

    
if u >= 1000000000000000000:
  print(-1)
else:
  print(u)

Submission status: Wrong Answer

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

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i
    if u >= 1000000000000000000:
      print(-1)
      break
    print(u)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split(' ')))
ans = 1
for l in A:
    ans *= l
    if 10**18 < ans:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC169 B-Multiplication2
class Calc():
  def multi(self,x,y):
    x, y, sign, rslt = str(x)+".", str(y)+".",1 ,""
    if x[0]=="-":
      sign*=-1
      x=x[1:]
    if y[0]=="-":
      sign*=-1
      y=y[1:]
    x,y=x.split("."),y.split(".")
    x2 = [int(x[1][-i-1]) for i in range(len(x[1]))] + [int(x[0][-i-1]) for i in range(len(x[0]))]
    y2 = [int(y[1][-i-1]) for i in range(len(y[1]))] + [int(y[0][-i-1]) for i in range(len(y[0]))]
    sum=[0]*(len(x2)+len(y2))
    for i, p in enumerate(y2):
      for j, q in enumerate(x2):
        K=i+j
        sum[K]+=p*q
        while sum[K]>9:
          sum[K+1], sum[K] = sum[K+1] + int(sum[K]/10) , sum[K]%10
          K+=1
    for i in range(len(sum)): rslt+=str(sum[-i-1])
    dclen=len(x[1])+len(y[1])
    if dclen>0: rslt=rslt[:len(rslt)-dclen]+"."+rslt[len(rslt)-dclen:len(rslt)]
    for i in range(len(rslt)):
      if rslt[i]=="0" and (rslt[i+1] if i<len(rslt)-1 else ".")!="." : continue
      else:
        rslt=rslt[max(i,0):]
        break
    return ("-" if sign==-1 else "")+rslt
  
  def max_2(self,x,y):
    X,Y=x,y
    x, y, rslt = str(x)+".", str(y)+".", ""
    if x[0]=="-" and y[0]!="-": return Y
    if x[0]!="-" and y[0]=="-": return X
    if x[0]=="-" and y[0]=="-": return #(略)
    x,y=x.split("."),y.split(".")
    size0,size1 = max(len(x[0]),len(y[0])), max(len(x[1]),len(y[1]))
    x[0],y[0] = "0"*( size0 - len(x[0]) ) + x[0] , "0"*( size0 - len(y[0]) ) + y[0]
    x[1],y[1] = x[1] + "0"*( size1 - len(x[1]) ) , y[1] + "0"*( size1 - len(y[1]) )
    for s in [0,1]:
      for i in range( size0 if s==0 else size1 ):
        p,q=int(x[s][i]),int(y[s][i])
        if p==q: continue
        elif p>q: return X
        elif p<q: return Y
    return X

N=int(input())
A=input().split()
R,lim="1","1"+"0"*17+"1"
if 0 in A: print(0)
else:
  for i in range(N): 
    R=Calc().multi(R,A[i])
    if Calc().max_2(lim,R)==R:
      print(-1)
      break
  else:
    print(R)

Submission status: Wrong Answer

Solution code:
def multiply(myList) : # define function to calculate the result of multiplication 

    result = 1 
    for x in myList: 
         result = result * x  
    return result  

N = int(input()) #input N

B = list(map(int, input().split(' '))) # Get the list from user
A = []

for i in range (0,N): # put all to list one to respect the total number of elements which is N
    c = B[i]
    A.append(c)

ans = multiply(A) # declare answer and put the list A in function 

if ans < pow(10,18): # check if ans is bigger than 10 power of 18 
    print(ans)  # print the result
else:
    print(-1) #print the Result

Submission status: Wrong Answer

Solution code:
def multiply(myList) : # define function to calculate the result of multiplication 
      
    
    result = 1 
    for x in myList: 
         result = result * x  
    return result  

N = int(input())

B = list(map(int, input().split(' ')))
A = []

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

ans = multiply(B)

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

Submission status: Wrong Answer

Solution code:
def multiply(myList) : # define function to calculate the result of multiplication 
      
    
    result = 1 
    for x in myList: 
         result = result * x  
    return result  

N = int(input())

B = list(map(int, input().split(' ')))
A = []

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

ans = multiply(A)

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

Submission status: Wrong Answer

Solution code:
def mulallnum(lst):  #multiply altogther the number
    result = 1
    for x in lst:
        result = result*x
    return result
n = int(input())
A = list(map(int, input().split(' ')))

if mulallnum(A) < 10**18:
    print(mulallnum(A))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def multiply(myList) : 
 
    # Multiply elements one by one 
    result = 1
    for x in myList: 
         result = result * x  
    return result  
 
N = int(input())
 
A = list(map(int, input().split(' ')))
 
ans = multiply(A)
 
if ans < pow(10,18):
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#multiply all numbers in list
def mulallnum(first):
    result = 1
    for x in first:
        result = result * x
    return result
n = int(input())
A = list(map(int, input().split(' ')))

if mulallnum(A) < 10**18:
    print(mulallnum(A))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#to multiply all numbers in list
def multiplyList(lst):
    result = 1
    for x in lst:
        result = result * x
    return result

#Drivercode
#generate list code
n = int(input())
A = list(map(int, input().split(' ')))

if multiplyList(A) < 10**18:
    print(multiplyList(A))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#user input N
#user input A in list
#function of multiplication of all item in list
#time complexity is O(n)
N = int(input())
A = [int(x) for x in input().split()[:N]]

def multiplyList(list1):
    b = 1
    for i in list1:
        b = b*i
    return b

if multiplyList(A) < 1*10**18:
    print(multiplyList(A))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# multiply all numbers in list given
def mulallnum(lst):
    result = 1
    for y in lst:
        result = result * y
    return result
n = int(input())
A = list(map(int, input().split(' ')))

if mulallnum(A) < 10**18:
    print(mulallnum(A))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#to multiply all numbers in list
def mulallnum(lst):
    result = 1
    for x in lst:
        result = result * x
    return result
n = int(input())
A = list(map(int, input().split(' ')))

if mulallnum(A) < 10**18:
    print(mulallnum(A))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 1
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans >= lim:
    l = 1
    break
  else:
    pass

if l == 1:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 1

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1

if '0' in str(A):
    print(0)
    sys.exit()

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

result = 1

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

Submission status: Wrong Answer

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

ans = 1
for a_i in a:
    ans *= a_i
    if ans > 1_000_000_000_000_000_000:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

prod = np.prod(A)

if prod <= 1000000000000000000:
    print(prod)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

prod = np.prod(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def Ii():return int(input())
def Mi():return map(int,input().split())
def Li():return list(map(int,input().split()))
n = Ii()
a = Li()
ans = 1
for i in a:
  ans *= i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
nl=list(map(int,input().split()))
s=sum(nl)
if((s//1000000000000000000)>=1):
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
res=1
arr.sort()
if arr[0] == 0 :
  print('0')
  exit(0)
for i in range(n):
  res = res*arr[i]
  if res>1e18:
    print(-1)
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
if 0 in A:
    print(0)
else:
    Π = 1
    for _ in A:
        Π *= _
        if(Π > 1000000000000000000):
            print(-1)
        else:
            print(Π)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

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

if((np.where(A == 0))[0]):
    print(0)
    sys.exit()

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        sys.exit(0)

print(Π)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

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

if((np.where(A == 0))[0]):
    print(0)
    sys.exit()

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        exit(0)

print(Π)

Submission status: Wrong Answer

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

Π = 0
for _ in A:
    Π *= _
    if(Π > 10e+18):
        print(-1)
        exit(0)

print(Π)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))
if (0 in lst):
  print(0)
else:
  product = 1
  for i in lst: #iというlist中の数字
    product *= i #これが(i + 1)番目

    if(product > 1000000000000000000):
      #これをfor文に書くことで掛け終える前に超えたらやめることができる（処理を短縮できる！）
      print(-1)
      break
    
  print(product)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))
if 0 in lst:
  print(0)
else:
  product = 1
  for i in lst:
    product *= i #これが(i + 1)番目

    if(product > 1000000000000000000):
      #これをfor文に書くことで掛け終える前に超えたらやめることができる（処理を短縮できる！）
      print(-1)
      break
    
  print(product)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))
if 0 in lst:
  print(0)
else:
  product = 1
  for i in lst:
    product *= i #これが(i + 1)番目

    if(product > 1000000000000000000):
      #これをfor文に書くことで掛け終える前に超えたらやめることができる（処理を短縮できる！）
      print(-1)
      exit
    
  print(product)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))
if 0 in lst:
  print(0)
else:
  product = 1
  for i in lst:
    product *= i #これが(i + 1)番目

    if(product > 1000000000000000000):
      #これをfor文に書くことで掛け終える前に超えたらやめることができる（処理を短縮できる！）
      print(-1)

  print(product)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    elif ans != -1:
        ans *= a

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int, input().split()))
i = 0
product = lst[0]
for i in range(N):
  product *= lst[i] #これが(i + 1)番目

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A = np.prod(a)
if A> 10**18:
    print("-1")
else:
    print(int(A))

Submission status: Wrong Answer

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

A = np.prod(a)
if A> 10**18:
    print("-1")
else:
    print(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

prod = np.prod(A)

if prod <= 10**18:
    print(prod)
elif prod > 10**18:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

prod = np.prod(A)

if prod <= 10^18:
    print(prod)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
res, flag = 1, False
for i in s:
  res *= i
  if res > int(1e18): flag = True; break
print(-1 if flag else res)

Submission status: Wrong Answer

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

cnt = 1

if 0 in a:
    print(-1)
else:
    for i in range(n):
        cnt = cnt * a[i]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10^8:
        print(-1)
        exit()
print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- codinf: utf-8 -*-
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:
# -*- codinf: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
print(A)
ans = 1
for a in A:
  ans *= 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 = 1
b = 10**18
for i in range(N):
    ans *=A[i]
    if ans >b:
        print(-1);exit()
print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
res = 1
c = False
b = sorted(b, key = int)
if b[0] == 0:
    print(0)
else:
    for i in range(a):
        if res > 10**18:
            c = True
            break
        res *= b[0]
    if c:
        print(-1)
    else:
        print(res)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
res = 1
c = False
b.sort(key = int)
if b[0] == 0:
    print(0)
else:
    for i in range(a):
        if res > 10**18:
            c = True
            break
        res *= b[0]
    if c:
        print(-1)
    else:
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int, input().split()))
mlt = 1
for x in l:
    mlt *= x
    if mlt > 10 ** 18:
        print('-1')
        exit()
print(mlt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
_ = input()
nums = list(map(int, input().split()))
ans = 1

for num in nums:
    if num==0 or ans <= 10 ** 18:
        ans *= num
    else:
        break

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

Submission status: Wrong Answer

Solution code:
_ = input()
nums = list(map(int, input().split()))
ans = 1
 
for num in nums:
    if ans <= 10 ** 18:
        ans *= num
    else:
       	print(-1)
        break
 
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
_ = input()
nums = list(map(int, input().split()))
ans = 1
 
for num in nums:
    if ans <= 10 ** 18:
        ans *= num
    else:
        break
 
print(ans if ans <= 10**18 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
_ = input()
nums = np.array(list(map(int, input().split())))
 
x = np.prod(nums)
print(x if 0 <= x and x <= 10**18 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np

_ = input()
nums = np.array(list(map(int, input().split())))

x = np.prod(nums)
print(x if x <= 10**18 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np

_ = input()
nums = np.array(list(map(int, input().split())))

x = np.prod(nums)
print(x if x < 10**18 else -1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
if 0 in A:
    result=0
for i in A:
    if result==0:
        break
    if result>1000000000000000000:
        result=-1
        break
    result*=i
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
for i in A:
    if 0 in A:
        result=0
        break
    if result>1000000000000000000:
        result=-1
        break
    result*=i
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
for i in A:
    if 0 in A:
        result=0
        break
    if A[0]>1000000000:
        result=-1
        break
    if result>1000000000000000000:
        result=-1
        break
    result*=i
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
  sys.exit()
 
for a in A:
  ans *= a
  if ans<=1e18:
    print(-1)
    sys.exit()
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 == 0:
    break
print(ans if ans<=10**18 else -1)
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
print(ans if ans<10**18 else -1)

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 > 10 ** 18:
        print(-1)
        exit(0)

print(ans)

Submission status: Wrong Answer

Solution code:
X = int(input())
p = input().split()
s = 1
for i in range(len(p)):
    s = s * int(p[i])
    if s > 10 ** 18:
        s = -1
        break
print(s)

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

n=IN()
a=LI()
p=1
if 0 in a:
    print(0)
    exit()
for i in a:
    p*=i
    print(p)
    if p>pow(10,18):
        print(-1)
        exit()
print(p)

Submission status: Wrong Answer

Solution code:
def mult(lst):
  ans = 1
  for num in lst:
    ans *= num
    if ans > 10 ** 18:
      return -1
  return ans

n = int(input())
if n > 0:
  a = map(int, input().split())
  print(mult(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
def mult(lst):
  ans = 1
  for num in lst:
    ans *= num
    if ans > 10 ** 18:
      return -1
  return ans
print(mult(a))

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 > 10**18:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def main ():
	N = int(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()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

M = int(1e18)
n = int(input())
s = list(map(int, input().split()))
res = 1
flag = False
for i in range(len(s)):
	res *= s[i]
	if res > M: flag = True; break
print(-1 if flag else res)

Submission status: Wrong Answer

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

res = 1
check = 10**18

for e in l:
    res *= e

if res >= check:
	print(-1)
else:
	print(res)

Submission status: Wrong Answer

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

res = 1
check = 10**18
if 0 in l:
  res = 0
else:
    for e in l:
      res *= e
      if res >= check:
          res = -1
          break
print(res)

Submission status: Wrong Answer

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

res = 1
check = 10**18

for e in l:
  res *= e
  if res > check:
      res = -1
      break
print(res)

Submission status: Wrong Answer

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

res = 1
check = 10**18

for e in l:
  res *= e
  if res >= check:
      res = -1
      break
print(res)

Submission status: Wrong Answer

Solution code:
a = int(input())
sum = 1
nums = list(map(int,input().split()))
for i in range(a):
  sum *= nums[i]
if sum<=10**8 :  
	print(sum)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
a = int(input())
sum = 1
nums = list(map(int,input().split()))
for i in range(a):
  sum *= nums[i]
  
print(sum)

Submission status: Wrong Answer

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

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