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: Runtime Error

Solution code:
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read.input())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    for num in a:
      ans *= num
      if ans > 10**18:
        flag = False
        break
    print(ans if flag else -1)
 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
num_list = list(map(int, input().split()))
result = 1

for number in num_list:
	result = result * number
  
def if_test(result):
	if 10 ** 18 < result:
        print(-1)
    else:
      	print(result)
        
if_test(result)

Submission status: Runtime Error

Solution code:
defmain():
  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: Runtime Error

Solution code:
import numpy as np
import sys
import collections

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

print(res)

Submission status: Runtime Error

Solution code:
ls = list(map(int, input().split()))
ans = 1
for l in ls:
  ans *= l
  if ans > 1e18:
    print(-1)
    return
print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(float,input().split())
ans = ((a*b*100) /100)// 1
print(int(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans*i
    if i == 0:
        print(0)
        ans = -1
        break
    elif ans > 1000000000000000000 and i !== 0:
        print(-1)
        ans = -1
        break
if ans != -1:
    print(ans)

Submission status: Runtime Error

Solution code:
N = ii()
A = li()
ans = 1
for num in A:
    if ans < 10**18 / num:
        #print(ans, 10**18 / num)
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
l = list(map(int, input().split()))
mul = 1
for num in l:
  mul *= num
  if mul > 1e18:
    print(-1)
 	break
print(mul)

Submission status: Runtime Error

Solution code:
n = input()
l = list(map(int, input().split()))
mul = 1
for num in l:
  mul *= num
  if mul > 1e18:
    print(-1)
   break
print(mul)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
sum = list(map(int,input().split()))
x = 1

for i in range(n):
    x *= sum[i]

if math.log(x,10)>18:
    print(-1)
    
else:
    print(x)

Submission status: Runtime Error

Solution code:
l = list(map(int, input().split()))
mul = 1
for num in l:
  mul *= num
  if mul > 1e18:
    print(-1)
 	break
print(mul)

Submission status: Runtime Error

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: Runtime Error

Solution code:
n = int(input())
sum = list(map(int,input().split()))
x = 1

for i in range(n):
    x *= list[i]

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

Submission status: Runtime Error

Solution code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        ans=ans*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()

Submission status: Runtime Error

Solution code:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    if 0 in a:
        print(0)
        return
    ans=1
    for i in a:
        pro=pro*i
        if pro>1000000000000000000:
            print(-1)
            return    
    print(ans)
    return
main()

Submission status: Runtime Error

Solution code:
n=int(input(""))
k=1
li=list(map(int,input("").split(" ")))
if 0 in li:
    print("0")
else:
    for i in li:
        k*=int(i)
    if k>1000000000000000000:
        print("-1")
        break
    else:
        print(k)

Submission status: Runtime Error

Solution code:
n=int(input(""))
k=1
li=list(map(input("").split(" ")))
if "0" in li:
    print("0")
else:
    for i in li:
        k*=int(i)
    if k>1000000000000000000:
        print("-1")
    else:
        print(k)

Submission status: Runtime Error

Solution code:
n = int(input())

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

if 0 in aList:
  print(0)
else:
  for i in range(n):
    if i == 0:
      continue
    result = result * aList[i]
    if result > 10 ** 18:
      result = -1
      break
  print(result)

Submission status: Runtime Error

Solution code:
n = int(input())

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

if 0 in aList:
  print(0)
else:
  for i in range(n):
    if i == 0:
      continue
    result = result * aList[i]

  enemy = 10 ** 18

  if result < enemy:
    print(result)
  else:
    print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())

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

if 0 aList:
  print(0)
else:
  for i in range(n):
    if i == 0:
      continue
    result = result * aList[i]

  enemy = 10 ** 18

  if result < enemy:
    print(result)
  else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
m=1
i=-1
while m<10**18 and i<=n:
  i+=1
  m*=l[i]
if i==n:
  print(m)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
import functools

n = int(input())
xs = input().split()

def foldSum(acc, x):
    return acc*int(x)

if 0 in res:
    print(0)
else:
    res = functools.reduce(foldSum, xs, 1)

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

Submission status: Runtime Error

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
for i in a:
    s *= i
    if s > 1e18:
        print(-1)
        exit()
print(s)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IS(): return str(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve(N,A):
    ans = 1
    if 0 in A:
        print(0)
        return
    
    for i in A:
        ans *= i
        if ans > pow(10,18)
            print(-1)
            return
    print(ans)

def main():
    N = II()
    A = LI()
    solve(N,A)

#main
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    if o in a:
        print(0)
        return
    
    res=1
    for i in a:
        res *= i
        if(res > 1000000000000000000:
            print(-1)
            return
    
    print(res)

main()

Submission status: Runtime Error

Solution code:
def main():
  n = int(input())
  a = list(map(int, input().split()))
  
  if 0 in a:
    print(0)
    return
  res=1
  for i in a:
    res*=i
    if(res > 1000000000000000000:
       print(-1)
       return
  print(res)
main()

Submission status: Runtime Error

Solution code:
A,B=input().split()
print(int(A)*int(B.replace(".", ""))//100)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    for i in a:
        if(i==0):
            print("-1")
            return
        sum*=i 

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

main()

Submission status: Runtime Error

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int, input().split()))
ans=1
for i in li:
    ans*=i
if ans >1000000000000000000:
	print("-1")
    exit()
else:
	print(ans)

Submission status: Runtime Error

Solution code:
while available > 1:
    for i in range(available / 2):
    nums[i] = nums[2 * i] * nums[2 * i + 1]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
    if isOdd:
        nums[available / 2 + 1] = nums[-1]
        available //= 2
    if isOdd:
        available += 1
    if a == 0:
        print(0)
        quit()
print(ans)
quit()

Submission status: Runtime Error

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

isOdd = num%2 == 1
available = range(len(nums))

while available > 1:
    for i in range(available / 2)
    nums[i] = nums[2 * i] * nums[2 * i + 1]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
    if isOdd:
        nums[available / 2 + 1] = nums[-1]
        available //= 2
    if isOdd:
        available += 1
    if a == 0:
        print(0)
        quit()
print(ans)
quit()

Submission status: Runtime Error

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

if 0 in A:
    print(0)
else:
    prob=1
    for a in A:
      prob*=a
if prob > 10**18:
    print(-1)
else:
    print(prob)

Submission status: Runtime Error

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

total = 1
a.sort()
if a[0] == 0:
	print(0)
	sys.exit(1)
for i in range(n):
	total *= a[i]
	if total > 10**18:
		print('-1')
		sys.exit(1)
print(total)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
A1=sorted(A)
Ans=1
an=0
t=10**18
while Ans <= t:
    if an <= len(A1):
        Ans=Ans*A1[an]
        an=an+1

if Ans > t:
    print(-1)
else:
    print(Ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
A1=sorted(A)
Ans=1
an=0
t=10**18
while Ans <=t:
    if an <= len(A1):
        Ans=Ans*A1[an]
        an=an+1

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

Submission status: Runtime Error

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

if 0 in A:
    print(0)
    return

prib=1
for a in A:
    prob*=a
    if prob > 10**18:
        print(-1)
        return
print(prob)

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    ll ans = 1;

    ll r = 1e18;

    vector<ll> a(n);

    for (auto &x : a)
    {
        cin >> x;
        if (x == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (1000000000000000000 / ans <= a[i])
        {
            cout << -1 << endl;
            return 0;
        }

        ans *= a[i];
    }

    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
import numpy as np
 
N = int(input())
A = list(map(int, input().split()))  
a = 1
if 0 in A:
	print(0)
for i in range(N):
  a *= *A[i] 
  if (a > 10**18):
  	a = -1
print(a)

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>1000000000000000000:
    print(-1)
else:
    print(int(L))

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L, dtype=Decimal))

if L>=1000000000000000001:
  print("-1")
else:
  print(int(L))

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>1000000000000000000:
    print("-1")
else:
    print(int(L))

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
A = list(map(int, input().split()))

ans = 1
if 0 in A:
  print(0)
  sys.quit()
  
for i in range(n):
  ans *= A[i]
  if ans > 1e18:
    ans = -1
    break

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
 
N = int(input())
A = list(map(int, input().split()))  
a = 1
if 0 in A:
	print(0)
for i in range(N):
  a = a*A[i] 
	if (a > 10**18):
  	a = -1
    return
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(map(int,input().split()))
if 0 in s:
  print(0)
  exit()
for _ in range(n):
  ans *= s[_]
  if len(str((ans-1))) > 18:
    print(-1)
    exit()
else:
  print(ans)

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>=1000000000000000001:
  print("-1")
else:
  print(int(L))

Submission status: Runtime Error

Solution code:
print(prod([int(input().split()) for _ in range (int(input()))]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans=1
c=0

while c<N:
    if A[c]==0:
        ans=0 break;
    else if ans*A[c]>10000000000000000:
        ans=10000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>10000000000000000: print(-1)
else: print(ans)

Submission status: Runtime Error

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

ans=1
c=0

while c<N:
    if A[c]==0: ans=0 break;
    else if ans*A[c]>10000000000000000: ans=10000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>10000000000000000: print(-1)
else: print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit()
    else:
        continue
print(ans)

Submission status: Runtime Error

Solution code:
_ = input()
inputs = list(map(lambda x: int(x), input().split()))

if 0 in inputs:
    value = 0
else:
    value = inputs[0]
    for n in range(1, len(inputs) + 1):
        value *= inputs[n]

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

Submission status: Runtime Error

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

if 0 in li:
  print(0)
  exit
else:
  ans=1
  for i in li:
    ans*=i
    if ans>10**18:
        print(-1)
        exit
    else:
        continue
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

a,b = input().split()
b = int(b.replace(".",""))
a = int(a)
print((a*b)//100)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

ans = 1

for a in alis:
  	ans *= a
	if ans > 10**18:
		ans = -1
		break

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

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

ans = 1

for a in alis:
  ans *= a
  if ans > 10**18:
	ans = -1
	break

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

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

ans = 1

for a in alis:
  ans *= a
  if ans > 10**18:
  	ans = -1
    break

print(-1)

Submission status: Runtime Error

Solution code:
#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
         exit()
print(ans)

Submission status: Runtime Error

Solution code:
n = input()
kakeru = map(int,input().split())
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 100000000000000000000:
    print(-1)
print(kakekake)

Submission status: Runtime Error

Solution code:
_ = input()
inputs = list(map(lambda x: int(x), input().split()))

current_text = ""

m= 0
for n in inputs:
    if m == len(inputs) - 1:
        current_text += str(n)
        break
    current_text += str(n) + "*"
    m += 1

value = eval(current_text)

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

Submission status: Runtime Error

Solution code:
def f(n, a):
  if 0 in a:
    return 0
  p = 1
  for x in a:
    p *= x
    if p > 10**18:
      return -1
  return p

n = int(input())
a = list(int, input().split())
print(f(n, a))

Submission status: Runtime Error

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

limit = 1000000000000000000

result = 1
for i in A:
  if result >= limit:
    result = -1
  	break
  result = result * i

print(result)

Submission status: Runtime Error

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

arr.sort()
flg = True
for i in arr:
    res*=i
    if res >10**18:
        flg = False
        print('-1')
    # print(res, res >=10**18)
if(flg):print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
print(a)
b=a.replace(' ', '*')
c=eval(b)
ans=c
if ans>10**18:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>=1000000000000000001:
    print("-1")
else:
    print(int(L))

Submission status: Runtime Error

Solution code:
def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
        x = 1
    else:
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int N;
    ll buf;
    cin >> N;
    ll sum = 1;
    bool flag = false;
    bool zeroflag = false;
    for (int i = 0; i < N; i++)
    {
        cin >> buf; 
        if(buf == 0){
            zeroflag = true;
        }
        if (flag == false)
        {
            if ((sum * buf) > 1000000000000000000)
            {
                flag = true;
            }
            sum = sum * buf;
        }
    }

    if(zeroflag){
        cout << 0 << endl;
    }
    else if(flag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << sum << endl;
    }
    return 0;
}

Submission status: Runtime Error

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

ans = 1

if A[0] == 0:
  print(0)
else:
  for a in A:
    ans *= a
    if ans > 1000000000000000000:
      print(-1)
      break
  print(ans)

Submission status: Runtime Error

Solution code:
n,*a=map(open(0).read().split())
if 0 in a:
  print(0)
  exit()
s=1
for i in a:
  s*=i
  if s>10**18:
    print(-1)
    exit()
print(s)

Submission status: Runtime Error

Solution code:
def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        	if x > 10**18:
            	print(-1)
                exit()
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

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

Submission status: Runtime Error

Solution code:
from math import log10

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        	if x > 10**18:
            	print(-1)
                exit()
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Runtime Error

Solution code:
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = map(int, input().split())
nums = list(map(int, input().split()))


count  = reduce(mul, nums)
if "0" in N:
        print("0")
for  num in nums
    ans *= num
        if count  > cnt :
        print(-1)

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def fun():
	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)



fun()

Submission status: Runtime Error

Solution code:
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            return
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#B
import numpy as np
import sys
n = int(input())
A = np.array(list(map(int,input().split())))
ans = 1
flag = True
for i in A:
    if flag:
        ans *= i
        if ans > 10**18:
            ans = -1
            flag = False
    else:
    if i == 0:
        ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
#B
import numpy as np
import sys
n = int(input())
A = np.array(list(map(int,input().split())))
ans = 1
flag = True
for i in A:
    if flag:
	    ans *= i
		if ans > 10**18:
    		ans = -1
            flag = False
	else:
		if i == 0:
          ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
package main

import (
	"fmt"
)

func main() {
	var n int
	var ans int = 1
	var t int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		ans = ans * t
		if ans > 1000000000000000000 {
			ans = -1
		}
	}

	fmt.Println(ans)
}

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal
import numpy as np
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>1000000000000000000:
    print("-1")
else:
    print(L)

Submission status: Runtime Error

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

flag = 0
if data.count(0) > 0:
  print(0)
else
	a = data[0]
	for i in range(1,n):
  		a = a*data[i]
        if a > 10**18:
          flag = 1
          break

	if flag == 1:
  		print('-1')
	else
		print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from decimal import Decimal
N=Decimal(input())
L=list(map(Decimal,input().split()))
L=Decimal(np.prod(L))

if L>1000000000000000000:
    print("-1")
else:
    print(L)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
if 0 in s:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import functools
import operator
def II(): return int(input())
def LII(): return double(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    #A = [0]*N
    ans = 1
    A= LI()
    
    if A.count(0)>0:
        print(0)
    else:
        for i in range(N):
            ans = ans*int(A[i])
            print(ans)
            if ans/1e+18>1:
                print(-1)
                break


        if ans/1e+18<=1:
            print(ans)
    


    


if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:

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

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