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:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    GI()
    CEIL = 10 ** 18

    prod = GI()
    for x in GIS():
        prod *= x
        if prod > CEIL:
            prod = -1
            break
    print(prod)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

t()

Submission status: Runtime Error

Solution code:
n,a = map(int.input().split())
b = list[]
for n:
  b.append(a)

c = a**n
if c > 10**18:
  c = -1
  print(c)

Submission status: Runtime Error

Solution code:
n,a = map(int.input().split())
b = list[]
for n:
  b.append(a)

plint(a**n)

Submission status: Runtime Error

Solution code:
def solve():
    N = int(input())
    A = eval(input().replace(' ', '*'))
    if A > 10**18:
        print(-1)
    else:
        print(A)


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

import numpy as np

N = int(input())

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

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

if np.sum(A > 0) % 2 == 1:
    print(np.prod(A))
    exit(1)

mul = A[0]
for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(1)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(1)

print(mul)

Submission status: Runtime Error

Solution code:
import sys
N=int(input())
if N>10**5 or N<2:
    sys.exit(1)
s=1
for i in range(N):
    a=input().rstrip()
    s*=int(a)
if s<10e+18:
    print(s)
else:
    print("-1")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def multipilation():
    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 > 10**18
            print(-1)
            return

    print(prod)
    
multipilation()

Submission status: Runtime Error

Solution code:
def multipilation():
    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 > 10**18
            print(-1)
            return

    print(prod)
    
    multipilation()

Submission status: Runtime Error

Solution code:
numa, numb = input().strip().split()
numa, numb = [int(numa), float(numb)]

numb *= 100
numb = int(numb)
ans = int((numa*numb)/100)
print(ans)

Submission status: Runtime Error

Solution code:
n_list=list(input().split())
a=int(n_list[0])
b=float(n_list[1])
ans=a*b
print(int(ans))

Submission status: Runtime Error

Solution code:
x=int(input())
list_a=list(input())
a=1
for i in range(0,x):
  a=a*list_a[i]
if a>=10^18 or a<0:
  print(-1)
else:
  print(a)

Submission status: Runtime Error

Solution code:
if min(As)==0:
    num=0
else:
    num=1
    for i in range(N):
        num *= As[i]
        if num>10**18:
            print("breakに突入")
            num=-1
            break

print(num)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = map(int, input().split())
pro = 1
for i in range(n):
    pro *= arr[i]
if pro > 1000000000000000000:
    pro = -1
print(pro)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
sum = 1
for i in a:
    if i == 0
    sum = sum * i
    break
    else
    sum = sum * i

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

Submission status: Runtime Error

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

import numpy as np

N = int(input())

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

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

if np.sum(A > 0) % 2 == 1:
    print(np.prod(A))
    exit(-1)

mul = A[0]
for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(-1)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
 
import numpy as np
 
N = int(input())
 
A = np.array(list(map(int, input().split())))
mul = np.prod(A)
 
if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

Submission status: Runtime Error

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

import numpy as np

N = int(input())

A = np.arrya(list(map(int, input().split())))
mul = np.prod(A)

if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

Submission status: Runtime Error

Solution code:
N=int(input())
A_N=[int(x) for x in input().split()]
ans=1
for A in A_N
  ans = ans*A
  if ans>1000000000000000000:
    ans=-1
    break
print(ans)

Submission status: Runtime Error

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

N = int(input())

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

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

mul = A[0]
for i in A[1:]:
    mul *= i
    
    if mul > 1000000000000000000:
        print(-1)
        exit(-1)

if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

Submission status: Runtime Error

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

N = int(input())

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

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

mul = A[0]
for i in A[1:]:
    mul *= i
    
    if mul > 1000000000000000000:
        print(-1)
        exit(-1)

print(mul)

Submission status: Runtime Error

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

N = int(input())

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

mul = A[0]
for i in A[1:]:
    mul *= i
    
    if mul > 1000000000000000000:
        print(-1)
        exit(-1)

print(mul)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if A in 0:
  print(0)
else:
  while N > i:
  	if ans > 10**18:
    	print(-1)
        exit()
    else:
      ans *= A[i]
print(ans)

Submission status: Runtime Error

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

ans ＝　1
if A in 0:
  print(0)
else:
  while N > i:
    if ans <= 10**18:
      ans *= A[i]
    else:
      print(-1)
      exit()
print(ans)

Submission status: Runtime Error

Solution code:
x, y = map(int, input().split())
for y in range(x):
  C = 1*Y
  if C >= 10^18:
    print(-1)
  else:
    print(C)

Submission status: Runtime Error

Solution code:
n = int(input())
mul = 1
for i in range(n):
  ai = int(input())
  mul = mul * ai
  if mul > 10 ** 18:
    print('-1')
    exit()

Submission status: Runtime Error

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

if 0 in A :
    res = 0
    N = 0

for x in range(N) :
    res *= A[x]
    if res > 10**18
        res = -1
        break

print(res)

Submission status: Runtime Error

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

if 0 in A :
    res = 0

for x in range(N) :
    res *= A[x]
    if res > 10**18
        res = -1
        break

print(res)

Submission status: Runtime Error

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

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10**18
        res = -1
        break

print(res)

Submission status: Runtime Error

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

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+18
        res = -1
        break

print(res)

Submission status: Runtime Error

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

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+18
        res = -1
        break

print(res)

Submission status: Runtime Error

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

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        res = -1
        break

print(res)

Submission status: Runtime Error

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

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        res = -1
        break

print(res)

Submission status: Runtime Error

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

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        print(-1)
        break

print(res)

Submission status: Runtime Error

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

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        print(-1)
        break

print(res)

Submission status: Runtime Error

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

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+18
        print(-1)
        break

print(res)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
s = 1
B = sort(A)
for i in B:
  s = s*i
	if s > 10**18:
    	s = -1
        break
    if s == 0
    	break
print(s)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
A=np.array[input()]
S=1

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

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 > 10**18:
    print("-1")
else:
    print(an

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())
a = list(map(int,input().split()))
m = 1
i = 0

while(N>i):
    m = m * a[N]
    i = i + 1

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

Submission status: Runtime Error

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

while(N>i):
	m = m * a[i]
    i = i + 1
if(m<=1000000000000000000):
    print(m)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
m = 1
i = 0
while(N>i):
 	m = m * a[i]
    i = i + 1
if(m<=1000000000000000000):
    print(m)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
m = 1
for i in range(0,N):
 	m = m * a[i]
    if(m<=1000000000000000000):
         print(m)
    else:
         print(-1)

Submission status: Runtime Error

Solution code:
def multi2_main(N,list):
    if (N == 0):
        return list[N]
    else:
        return list[N] * multi2_main(N-1,list)


N = int(input()) - 1
a = list(map(int,input().split()))

m = multi2_main(N,a)

if(m<=1000000000000000000):
	return m
else:
    return -1

Submission status: Runtime Error

Solution code:
def multi2_main(N,list):
    if (N == 0):
        return list[N]
    else:
        return list[N] * multi2_main(N-1,list)

def multi2():
    N = int(input()) - 1
    a = list(map(int,input().split()))

    m = multi2_main(N,a)

    if(m<=1000000000000000000):
        return m
    else:
        return -1


if __name__ == "__main__":
    print(multi2())

Submission status: Runtime Error

Solution code:
def multi2():
    N = int(input())
    a = input().split()
    m = 1
    for i in range(0,N):
        m = m * a[i]
    if(m<=1000000000000000000):
        return m
    else:
        return -1


if __name__ == "__main__":
  print(multi2())

Submission status: Runtime Error

Solution code:
def multi2():
    N = int(input)
    a = input().split()
    m = 1
    for i in range(0,N):
        m = m * a[i]
    if(m<=1000000000000000000):
        return m
    else:
        return -1


if __name__ == "__main__":
  print(multi2())

Submission status: Runtime Error

Solution code:
n = int(input())
res = 1
for i in range(n):
	res *= int(input())
	if(res > 1000000000000000000):
		print(-1)
		break
	elif(i == n-1):
		print(res)

Submission status: Runtime Error

Solution code:
n = (int)(input())
res = (int)(1)
for i in range(n):
	res *= (int)(input())
if(res > 1000000000000000000):
	print(-1)
else:
	print(res)

Submission status: Runtime Error

Solution code:
N = input()
nums = input().split()
res = int(nums.pop(0))

if 0 in nums:
  print('0')
  return

for i in nums:
  res *= int(i)

print(res)

Submission status: Runtime Error

Solution code:
N = int(input())
li = []
C = 1
while C <= 10**18:
	for i in range(N):
		li.insert(i,int(input())
    	C *= li[i]
if C <= 10**18:
	print(C)
else: print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
li = list(map(int,input()))
C = 1
for i in range(N):
  C *= li[i]
if C <= 10 ** 18:
  print(C)
else: print(-1)

Submission status: Runtime Error

Solution code:
N = input()
A = eval(input().replace(" ","*"))
if A > 10**18:
    print(-1)
else: print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
vals = [int(v) for v in input().split()]

rslt = 1

for v in vals:
  rslt = rslt * v
  
  if rslt > 10 ** 18:
    rslt = '-1'

print(rslt)

Submission status: Runtime Error

Solution code:
N = int(input())
vals = [int(v) for v in input().split()]

rslt = 1

for v in vals:
  rslt = rslt * v
  
  if rslt > 10 ** 18:
    print(-1)
	import sys
    sys.exit()
    
print(rslt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()

num = input().split()
num_list = [int(i) for i in num]

x = num_list[0]

for i in num_list[1:len(num_list)]:
  x *= i
  
  if x > 10 ** 18:
  print("-1")
  break

if x < 10 ** 18:
  print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input()).split())
if 0 in a:exit(print(0))
ans=1
for i in a:
  ans*=i
  if ans>10**18:exit(print(-1))
print(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 range(A):
        ans += A[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
if 0 in A:
	print(0)
	exit()

ans = 1

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

const double eps = 1e-9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 1;
  vector<long long> a(n);
  bool ok = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) ok = true;
  }
  if (ok) {
    cout << "0\n";
    return 0;
  }
  double foo = (double)1e18;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << "0\n";
      return 0;
    }
    double bar = foo / a[i];
    if (bar < 1.0 * ans) {
      cout << "-1\n";
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << '\n';
  return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
a_L = list(map(int,input().split())
a_L = list(sorted(a_L))
           
if a_L[0] == 0:
  print(0)

ans = 0

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

Submission status: Runtime Error

Solution code:
for _ in range(int(input())):
  nums = list(map(int, input().split()))
  mult = 1
  for num in nums:
    mult *= num
  mult = str(mult)
  if len(mult) > 17:
    print(-1)
  else:
    print(mult)

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)

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)

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)

Submission status: Runtime Error

Solution code:
def main():
  a = 1
  n = int(input())
  b = input().split()
  if 0 in b:
    print(0)
    return
  else:  
    for i in b:
        a *= int(i)
        if a > 10**18:
          print("-1")
          return
	print(a)

Submission status: Runtime Error

Solution code:
n = input()
S = int,input().split()

#n = 5
#S = [1,2,3,4,5]

ans = 1
#print(n)
#print(S)
#print(ans)

for number in S:
    ans = ans * number
#    print(ans)

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

Submission status: Runtime Error

Solution code:
n = input()
l = int, input().split(",")
ans = 1

for number in l:
  ans = ans * number

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
flag=0
ans=1
for _ in range(n):
  x=int(input())
  if ans>10**18:
    flag=1
  else:
    ans*=x
if flag:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
flag=0
ans=1
for _ in range(n):
  x=int(input())
  ans*=x
  if ans>10**18:
    flag=1
    break
if flag:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
long long T=1000000000000000000;
int main(){
	int n;cin>>n;
	long long mul=1;
	for(;n--;){
		long long x;cin>>x;
		if(T<x)return puts("-1")*0;
		else{
			if(x==0){
				cout<<0<<'\n';
				return 0;
			}
			T/=x;
			mul*=x;
		}
	}
	cout<<mul<<'\n';
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = 1
for i in range(n):
	a = a*int(input())
print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = 1
for i in range(n)
 a*int(input())
print(a)

Submission status: Runtime Error

Solution code:
input()
ans = eval(input().replace(" ", "*"))
if ans > 10**18:
        print(-1)
else:
        print(ans)

Submission status: Runtime Error

Solution code:
input();print(eval(input().replace(" ", "*")))

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())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( int(i) == 0):
        print(0)
        return
    product = product * int(i)

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

Submission status: Runtime Error

Solution code:
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( i == 0):
        print(0)
        return
    product = product * int(i)

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(n):
    p = p * a[i]
    
if p<= 10**18:
    print(p)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
L=[]
L=list(map(int,input().strip().split()))
Ll=len(L)
Ls=1
for i in range(Ll):
  	Ls=Ls*L[i]
if Ll<10^18
	print(Ls)
else:
	print(int(-1))

Submission status: Runtime Error

Solution code:
L=[]
L=list(map(int,input().strip().split()))
Ll=len(L)
Ls=1
for i in range(Ll):
  	Ls=Ls*L[i]
if Ls<10^18
	print(Ls)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
L=[]
L=list(map(int,input().strip().split()))
Ll=len(L)-1
Ls=1
for(int i=0,i<Ll;i++):
  	Ls=ls*L[i]
if 10^18>Ls:
  print(LS)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
m = 1
for n in range(n):
  i = int(input())
  m = m * i
  if m > 10 ** 18:
    m = -1
    break
print(m)

Submission status: Runtime Error

Solution code:
N = int(input())
m = 1
for n in range(n):
  m = m * n
  if m > 10 ** 18:
    m = -1
    break
print(m)

Submission status: Runtime Error

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
  	if num == 0:
    	print(0)
        quit()
    ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))

Submission status: Runtime Error

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
	ans *= num
    if ans > lim:
    	break
if ans > lim:
	print(-1)
else:
	print(int(ans))

Submission status: Runtime Error

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
	if ans <= lim:
    	ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))

Submission status: Runtime Error

Solution code:
N=input()
nums=input().split(" ")
result=1
for i in range(N):
  result*=nums[i]
 
if(result>1000000000000000000):
  print("-1")
else:
  print(result)

Submission status: Runtime Error

Solution code:
H=[]
H.input=map(int,input())
Hnum=H.len()
Hx=1
for(int =0;i<Hnum-1;i++):
  Hx=Hx*H[i]
print(Hx)

Submission status: Runtime Error

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

ans = 1
if N<1:
	return ans=0
else:
	for i in range(N):
       ans *= A[1]
	if ans > 10**18?reutrn -1:ans

Submission status: Runtime Error

Solution code:
input()
a = eval(input().replace(' ','*'))
if a <= 10**18:
    print(a)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
input()
a = eval(input().replace(' ','*'))
print([a,-1][a>10**18])

Submission status: Runtime Error

Solution code:
input()
a = eval(input().replace(' ','*'))
print([a,-1][a>=10**18])

Submission status: Runtime Error

Solution code:
n = int(input())
ret = 1
for _ in range(n):
  k = int(input())
  ret = ret * k
if ret < 10**18:
   print(ret)
else:
   print(-1)

Submission status: Runtime Error

Solution code:
n = input()
li = []
ret = 1
for _ in range(n):
  k = input()
  ret = ret * k
if ret < 10**18:
  print(ret)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = 10 ** 18
p = n - 1

ans = a[0]
for i in range(1, p):
    ans *= a[i]
    if ans > m:
        print("-1")
        sys.exit()

print(ans)

Submission status: Runtime Error

Solution code:
k=int(input());
res=1;
a=0;
for i in range(0,k):
  a=int(input());
  res*=a;
  if(res>pow(10,18)):
    print("-1");
    quit();
print(res);

Submission status: Runtime Error

Solution code:
k=int(input());
res=1;
a=0;
for i in range(0:k):
  a=int(input());
  res*=a;
  if(res>pow(10,18)):
    print("-1");
    quit();
print(res);

Submission status: Runtime Error

Solution code:
k=int(input());
res=1;
a=0;
for i in range(0:k):
  a=int(input());
  res*=a;
  if(res>pow(10,18)):
    print("-1");
    return;
print(res);

Submission status: Runtime Error

Solution code:
a,b=input().split()
print(int(a)*int(b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

main()

Submission status: Runtime Error

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

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

main ()

Submission status: Runtime Error

Solution code:
n=int(input());
m=1;
count=0;
while(count<n):
    count=count+1;
    q=int(input())
    m=m*q

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

Submission status: Runtime Error

Solution code:
n=int(input());
m=1;
count=0;
while(count<n):
    count=count+1;
    q=int(input())
    m=m*q;

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

Submission status: Runtime Error

Solution code:
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

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


print(prod)

Submission status: Runtime Error

Solution code:
import sys

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

zero_search = 0 in a_list
ans = 1

if zero_search:
    ans = 0
else:
    for i in a_list:
        ans *= i
        if ans > 10**18;
            ans = -1
            break
            
print(-1)

Submission status: Runtime Error

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