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:
a = int(input())
b = input().split(" ")
i = 0
s = 1
while i < a :
    s = s * int(b[i])
    i = i + 1
if s > (10 ** 18) :
    print("-1")
else:
    print(s)

Submission status: Runtime Error

Solution code:
sys.setrecursionlimit(1000000)
n = int(input())
l = list(map(int, input().split()))
b = 1
for a in l:
    b = b * a 
if b > 10 ** 18:
    b = -1
print(b)

Submission status: Runtime Error

Solution code:
import math

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

sum = 0
for i in range(n):
  sum += math.log10(a[i])

if sum >= 18:
  print(-1)
else:
  sum = 1
  for i in range(n):
    sum *= a[i]
  print(sum)

Submission status: Runtime Error

Solution code:
N = input()
ans = 1
for i in range(N):
	temp = input()
    if ans <= 10**18:
		ans = ans * temp
if ans <= 10**18:
	print(ans)
else:
	print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
mx = 1000000000000000000

for _ in range(int(input())) :
	arr = list(map(int, input().split()))
    ans = 1
    for ele in arr :
		ans = ans * ele
		if (ans > mx) :
			print(-1)
		else :
			print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy
n = int(input())
ls = list(map(int, input().split()))
if 0 in ls:
    print(0)
res = numpy.prod(ls)
elif res > 10**18:
    print(-1)
else:
    print(numpy.prod(ls))

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())
list = [input() for _ in range(N)]

result = functools.reduce(operator.mul, list)

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

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(map(int, input().split()))
import math
a = 0
b = 1
for i in range(n):
  a += math.log(x[i], 10)
if a > 18:
  print('-1')
else:
  for i in range(n):
    b *= x[i]
  print(b)

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

print(ans)

Submission status: Runtime Error

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

result = 1
m = 0
while result <= 10**18:
  result *= alist[m]
  m += 1

if m < n or result > 10**18:
  print("-1")
else:
  print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

N = int(input())

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

result = 1
for i in range(N):
    result *= NList[i]
    
    if result > 10 ** 18:
        print('-1')
        sys.exit(1)

if result > 10 ** 18:
    print('-1')
    sys.exit(1)
else:
    print(result)

Submission status: Runtime Error

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

ans = 1

for num in arr:
	ans *= num
	
if ans > 10**18:
	print(-1)
else:
	print(ans)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def product_many(N):
    if 0 in N: return 0
    ans = 1
    for x in N:
        if (10 ^ 18 / ans) < x: return -1  
        ans *= x
        if ans > 10 ^ 18: return -1
    return ans

def main():
    _ = input()
    N = list(map(int, input().split()))
    print(product_many(N))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

n=int(input())
ar=list(input())
ans=1
for i in range(n):
  ans*=ar[i]
  if(ans>math.pow(10,18)) :
    break
if(ans>math.pow(10,18)) :
  print("-1")
else :
  print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int(input().strip().split())))
pro=1
flag=0
for i in range(n):
    pro=pro*arr[i]
    if(pro==0):
        print(0)
        flag=1
        break
    elif(pro>(10**18)):
        print(-1)
        flag=1
        break
if(flag==0):
    print(pro)

Submission status: Runtime Error

Solution code:
import numpy
n = int(input())
ls = [int(input()) for _ in range(n)]
if 0 in ls:
    print(0)
res = numpy.prod(ls)
elif res > 10**18:
    print(-1)
else:
    print(numpy.prod(ls))

Submission status: Runtime Error

Solution code:
import sys

N = int(input())

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

result = 1
for i in range(N):
    result *= NList[i]
    
    if result > 10 ** 18:
        print('-1')
        sys.exit(1)

if result > 10 ** 18:
        print('-1')
        sys.exit(1)
else:
    print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
if N*A*B < 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(N*A*B)
elif N*A*B > 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(-1)

Submission status: Runtime Error

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

if 0 in a_list:
  print(0)
  

else:
  flg = True
  num = 1
  for a in a_list:
    num *= a
    if num > 1E18:
      print(-1)
      flg = False
      break

if flg:
  print(num)

Submission status: Runtime Error

Solution code:
n= int(input())
a=list(map(int,input().split()))
ans = 1
if not 0 in a:
  for i in range(n):
    ans*=a[i]
    if ans>1e+18:
      print(-1)
      break     
  if ans<=1e+18:
    print(ans)
eles:
  print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = [int(x) for x in input().split(" ")]
product = 1
for a in A:
    product = product * a
if product > 10 ** 18:
    print(-1)
    sys.exit(1)

print(product)

Submission status: Runtime Error

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

a = 1
while i<n:
  a = a*data[i]
  i += 1
  if a > 10^18:
    a = -1

print(a)

Submission status: Runtime Error

Solution code:
a=int(input())
mul=1

for i in range(a):
  x=int(input())
  mul=mul*x
if mul>1000000000000000000:
  print('-1')
else:
  print(mul)

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
if A*B < 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(A*B)
elif A*B > 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(-1)

Submission status: Runtime Error

Solution code:
N=input()
if not N:
	break
a=list(map(int, input().split(" ")))
ans=1
for v in a:
	ans*=v
if 1000000000000000000 < ans:
	ans = -1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 1
for _ in range(n):
	x = int(input())
	ans = ans * x
if ans > 1000000000000000000:
	ans = -1
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import tqdm
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int, input().split()))
ma = int(1e18)

for p_ in p:
    if p_ == 0:
        print(0)
        exit()

ans = 1
for p_ in p:
    ans *= p_
    if ans > ma:
        print(-1)
        exit()
print(ans)

Submission status: Runtime Error

Solution code:
input = sys.stdin.readline
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = 1
flag = False
for _ in range(n):
  d = int(input())
  a *= d
  if a > 10**18:
    flag = True
    break
if flag:
  print(-1)
else:
  print(a)

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
if 0 in A:
    print(0)
else:
    ans = 1
    flag = 0
    for i in range(N):
        a = A[i]
        cur *= a
        if cur > MAX:
            flag = 1
            break
    if flag == 1:
        print(-1)
    else:
        print(cur)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
n = int(input())
q = 1000000000000000000
b = 1
cek = True
a = list(map(int, input().split()))
for i in range(n):
	b = b * a[i] 
	if b > q :
		cek = False
		break
if cek :
	print(b)
else :
	print("-1")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import prod
n = int(input())
arr = list(map(int,input().split()))
if prod(arr) > 10**18:
  print(-1)
else:
  print(prod(arr))

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

N = int(input())
x = [int(input()) for i in range(N)]
y = reduce(mul, x)

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

Submission status: Runtime Error

Solution code:
while True:
	N=input()
	if not N:
		break
	a=list(map(int, input().split(" ")))
	ans=1
	for v in a:
		ans*=v
	if 1000000000000000000 < ans:
		ans = -1
	print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 1
flg = True

if '0' in list(input().split()):
    print(0)
else:
    for a in input().split():
        _a = int(a)
        ans *= _a
        if ans > 10 ** 18:
            print(-1)
            flg = False
            break

    if flg:
        print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
re = 1

for i in range(n):
  m = int(input())
  
  re *= m
if(re >= 1000000000000000000):
    print("-1")
else:
    print(re)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

def solve(n):
    

def main():
    test_num = inp()
    for _ in range(test_num):
        n = inp()
        answer = solve(n)
        print(answer)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
331import math
l1=list(map(int,input().split()))
a=math.prod(l1)
if a>10**18:
  print("-1")
else:
  print(a)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

if math.log10(answer) > 18:
    print("-1")
else:
    print(answer)

Submission status: Runtime Error

Solution code:
n = int(input())

total = 1
for i in range(n):
  x = int(input())
  total = total*x

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input()]
sum = 1

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

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

print(sum)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int lli;
#define MAX 100005
#define endl "\n"
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n;
	cin>>n;
	lli mask = 1;
	lli temp;
	bool flag = false;
	bool fzero = false;
	for(lli i = 0; i<n; i++){
		cin>>temp;
		mask *= temp;
		if(mask < 0 || mask > 1000000000000000000){
			flag = true;
		}
		if(temp == 0)
			fzero = true;
	}
	if(fzero){
		cout<<0<<endl;
		return 1;
	}
	if(flag){
		cout<<"-1"<<endl;
		return 1;
	}
	cout<<mask<<endl;
}

Submission status: Runtime Error

Solution code:

N = int(input())
A = list(map(int, stdin.readline().split()))
ans = 1
for a in A:
    ans = ans* a
    if ans >= 10**18:
        break

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

Submission status: Runtime Error

Solution code:
n = int(input())
ar = map(int,input.split())
mul = 1
for i in ar:
  mul*=i
  if mul>1000000000000000000:
    break
if mul>1000000000000000000:
  print(-1)
else:
  print(mul)

Submission status: Runtime Error

Solution code:
K = int(input())
N = input().split()

s = "*".join(N)
ans = eval(s)
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)
else:
    s=1
    for i in a:
    s=s*i
    if s>10**18:
        s=-1
        break
    print(s)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 1
s = input()
a = [int(x.strip()) for x in s.split(' ')]
if 0 in a:
  print(0)
  return
for i in range(n):
  ans *= a[i]
  if ans>1000000000000000000:
    print(-1)
    return
print ans

Submission status: Runtime Error

Solution code:
a=int(input())
b=input.split(' ')
m=0
s=0
while m<a:
    s=s+int(b[m])
    m=m+1
if s<10**18:
    print(-1)
else:
    print(s)

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
if A*B > 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(A*B)
elif A*B < 10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10:
	print(-1)

Submission status: Runtime Error

Solution code:
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

def main():
    N = int(input())

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        logsum += math.log10(a)

    if logsum >= 18:
        print('-1')
        return

    for a in As:
        prod *= a

    print(prod)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Runtime Error

Solution code:
def resolve():
    import numpy as np
    N = int(input())
    list = list(map(int, input().split()))
    print(numpy.prod(list) if numpy.prod(list)<=10**18 else "-1")
resolve()

Submission status: Runtime Error

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int INF=1e18;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int ans=1;
    while(n--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            ans=0;
            break;
        }
        if(INF/ans/a==0)
            ans=INF+1;
        else
            ans*=a;
    }
    if(ans>INF)
        ans=-1;
    cout<<ans;
}

Submission status: Runtime Error

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

if 0 in A:
  print(0)
elif:
  result = 1
  for n in range(N):
    result = result*A[n]
  if result>1000000000000000000:
    print(-1)
  else:
    print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
num = list(map(int, input().split()))
ans = num.prod()

Submission status: Runtime Error

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

import functools
import operator

ans = functools.reduce(operator.mul, A)

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if A<=100000000000000000 else -1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
str_list = input().split()

result = 1

for i in range(n):
  result = result * int(str_list[i])
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * a[i]
    if m = 0:
        break
    

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

Submission status: Runtime Error

Solution code:
N=input()
li = input().split()
result = 1
for i in range(N):
  if li[i] > 10**18 or result * li[i] > 10**18:
    result = -1
    break
  else:
    result = result * li[i]
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
n = int(input())
q = 1000000000000000000
b = 1
cek = True
a = list(map(int, input().split()))
for i in range n :
	b = b * a[i] 
	if b > q :
		cek = False
		break
if cek :
	print(b)
else :
	print("-1")

Submission status: Runtime Error

Solution code:
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = a[0]
    for i1 in range(1, n):
        if r > largenum:
            print(-1)
            sys.exit()
        else:
            r *= a[i1]
    print(r)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
def f(i):
  if i==0:
    return 1
  else:
    return f(i-1)*A[i-1]
a=f(N)
print(a if a<=10**(18) else -1)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [map(int, input().split())]
ans = int(0)
for i in A:
  ans *= i
  if ans >= 1e18:
    ans = -1
    break

Submission status: Runtime Error

Solution code:
N = input()
A = list(map(int, input().split))
tar = 1
for i in range(N):
    tar *= A[i]

print(tar)

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
if 0 in A:
    print(0)
else:
    ans = 1
    flag = 0
    for i in range(N):
        a = A[i]
        cur *= a
        if cur > MAX:
            flag = 1
            break
    if flag == 1:
        print(-1)
    else:
        print(cur)

Submission status: Runtime Error

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

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.0e0
for i in A:
    ans *= i
if ans > 10**18:
    ans = -1
print(int(ans))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
str_list = input().split()

result = 1

for i in range(n):
  result = result * int(str_list(i))
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
p=[int(input()) for i in range(N)]
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
import math
ans = 1
for i in range(len(A)):
    ans = ans*A[i]
ans2 = math.log(asn, 10)
if ans2<= 18:
    print(ans)
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

def input():
    return sys.stdin.readline()[:-1]


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

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

Submission status: Runtime Error

Solution code:
a=int(input())
b=input.split()
m=0
s=0
while m<a:
    s=s+int(b[m])
    m=m+1
if s<10**18:
    print(-1)
else:
    print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
arr = [int(x) for x in input().split()]
found = false
for x in arr:
  if x == 0:
    found = True
if found:
  print(0)
  exit(0)
res = 1
MAX = 10 ** 18
for x in arr:
  res *= x
  if res > MAX:
    print(-1)
    exit(0)
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import functools
import operator

f = functools.partial(functools.reduce, operator.mul)

_ = input()
A = list(map(int, input().split()))
res = f(A)
if res > 10**18:
  print(-1)
  else:
    print(res)

Submission status: Runtime Error

Solution code:
def main():
  n = int(input())
  ans = 0
  for i in range(n):
    ans *= int(input())
  if ans >= 10 ** 18:
    print(-1)
  else:
    print(ans)


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
n = int(input())
str_list = input().split()

result = 1

for i in range(n):
  result = result + str_list(i)
  
t = 1
for j in range(18)
  t = t * 10
if(result > t):
  print('-1')
else:
  print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
if A in 0:
    ans = 0
else:
    ans = 1
    check = 10 **18
    for i in range(N):
        ans *= A[i]
        print(ans)
        if ans > check:
            ans = -1
            break
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 > 10 ** 18:
	  print("-1")
      break
  else:
    continue
else:
  print(ans)

Submission status: Runtime Error

Solution code:
#intの場合
N = int(input()) #ここで標準入力
print (type(N),N) 
#<class 'int'> 20

#List にしたい時
#intの場合
huga = list(map(int, input().split()))
print(type(huga),huga)
# <class 'list'> [12, 34]
print(type(huga[0]),huga[0])
# <class 'int'> 12

ans = 1

for int i in huga:
    ans = ans * i

print(ans)

Submission status: Runtime Error

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

ans,flag = 1,0
for elem in arr:
  ans = ans*elem
  if ans>1e18:
  	flag=1
    break
    
if flag==1: print(-1)
else: print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

count = 1

for i in A:
    if A > 10**18:
        print(-1)
        exit()

for i in A:
    count *= i

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

Submission status: Runtime Error

Solution code:
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

def main():
    N = int(input())

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        logsum += math.log10(a)
        prod *= a

    if logsum > 18:
        print('-1')
        return

    print(prod)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())