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 numpy as np
N=int(input())
A=list(map(int, input().split()))
A_N=np.array(A,dtype='int64')

ANS=np.prod(A_N)

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

Submission status: Runtime Error

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


def mul(arr):
    if len(arr) == 1:
        return arr[0]
    return arr[0] * mul(arr[1:])


res = mul(A_s)

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

print(res)

Submission status: Runtime Error

Solution code:
n = input()
A = [int(x) for x in input().split()]
product = 1
 
for a in A:
    product *= a
    if a = 0:
        break
 
print(product if product <= 10**18 else -1)

Submission status: Runtime Error

Solution code:
n = int(input())

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

result = aList[0]

for i + 1 in range(n):
  result = result * aList[i]

enemy = 10 ** 18

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

Submission status: Runtime Error

Solution code:
_=input()
A=eval('*'.join(input().split()))
print(-1 if A>1000000000000000000 else A)

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(-1)
else:
    print(int(ans[N-1]))

Submission status: Runtime Error

Solution code:
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
# prod = functools.partial(functools.reduce, operator.mul)
# sum = functools.reduce(operator.mul, A, 1)
# a = np.array(A, dtype=int)
# print(a)
# print(np.prod(a))

lim = False
zero = False
sum = reduce(lambda a, b: a * b, A)
# for i in A:
#     if i == 0:
#         zero = True
#         break

# if int(zero) == 0:
#     for i in A:
#         sum = sum * int(i)
#         if 1000000000000000000 < sum:
#             lim = True
#             break

if if 1000000000000000000 < sum:
    print(-1)
# elif zero:
#     print(0)
else:
    print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    ans=ans*a[i]
    i+=1
    if(ans>1000000000000000000):
        if(0 in a==false):
            print(-1)
            exit()
        else:
            print(0)
            exit()
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = A[0]
exist_zero = False
def solve(A):
  if A[-1] == 0:
    exist_zero = True

  if exist_zero:
    print(0)
    return

  for i in range(1, N):
    ans *= A[i]
    if ans > 10**18 and not exist_zero:
      print(-1)
      return

  print(ans)

solve(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

list = [i for i in input().split()]

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

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

print(ans)

Submission status: Runtime Error

Solution code:
def multiplyList(myList): 
    result = 1
    for x in myList: 
        result = result * x 
    return result 
 
l= []
for i in range(int(input())):
    l.append(int(input()))
multiplyList(l)
if(multiplyList(l)>1000000000000000000):
    print("-1")
else:
    print(multiplyList(list1))

Submission status: Runtime Error

Solution code:
N = int(input())
Alist = list(map(int, input().split()))
p = 1
flag = True
roop_flag = True

if 1 in Alist:
    Alist.remove(1)

if 0 in Alist:
    p = 0
    roop_flag = False
elif len(Alist) >= 60:
    flag = False2
    roop_flag = False
    
for i in Alist:
    if roop_flag:
        p *= i
        if p >10**18:
            roop_flag = False
            flag = False
            break
        else:
            continue
    
if flag:
    print(p)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
from fractions import Fraction
import math

n = int(input())
num = list(map(int, input().split()))
num = [ Fraction(i) for i in num ]

if 0 in num:
    print(0)
elif len([i for i in num if i >= 10**18]) != 0:
    print(-1)
else:
    mult = math.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(int(mult))

Submission status: Runtime Error

Solution code:
import sys
def main():

n=int(input())
p=tuple(map(int,input().split()))
s=1
for i in range(n):
    s*=p[i]
if s>=10**18+1:
    print(-1)
    sys.exit()
print(s)

if __name__ == '__main__':
main()

Submission status: Runtime Error

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


input()
l = list(map(lambda x: int(x), str(input()).split(" ")))
r = 1
finished = False
for i in l:
    r = r * l
    if r > 10 ** 18:
        print(str(-1))
        finished = True
        break

if not finished:
    print(str(r))

Submission status: Runtime Error

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

ans=1
for i in range(n):
	ans*=a[i]
	if(ans>1000000000000000000):
		break;
	if(ans==0):
		break;

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
checker =False
for j in a:
  if j > 1000000000000000000:
    result = -1
    checker =True
if 0 in a:
  result = 0
  checker=True
while checker==False:
  import numpy as np
  a = np.array(a)
  result = a.prod()
  checker = True
    

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	int n; cin >> n;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(All(v));
    if(v[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = v[n-1];
    for(int i = 0; i < n-1; i++){
        ans *= v[i];
        if(ans > (ll)1e18){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans < 0){
        cout << -1 << endl;
    }
    else cout << ans << endl;
    system("pause");
}

Submission status: Runtime Error

Solution code:
n = int(input())
ans = 1
for i in range(0, n):
	t = int(input())
	ans *= t
if ans > int(1e18):
	print(-1)
else:
	print(ans)

Submission status: Runtime Error

Solution code:
c = int(1)
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
for k in range(N):
    c*=i[k]
    if c>10**18:
        print('-1')
        return
if c<10**18
      print(c)

Submission status: Runtime Error

Solution code:
import decimal

N = int(input())

AList = [decimal.Decimal(element) for element in input().split(" ")]

result = 1

for element in AList:
    result += result * element

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

while ans <the:
    if 0 in A:
        print(0)
        ans = the
        break
    ans *= A[i]

if ans < the:
    print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long curr_num, sum;
  int n;
  bool to_continue=true;
  cin >> n;
  cin >> sum;
  for (int i = 1; i < n; i++) {
    cin >> curr_num;
    if (to_continue) {
      if (1000000000000000000/curr_num < sum) {
        to_continue = false;
        sum = -1;
      }
      else if (curr_num * sum > 1000000000000000000) {
        to_continue = False;
        sum = -1;
      }
      else {
        sum *= curr_num;
      }
    }
  }
  cout << sum;
}

Submission status: Runtime Error

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

def func(n, a, i):
  if i == n:
    return 1
  return a[i] * func(n, a, i + 1)

res = func(n, a, 0)
if (res > 1000000000000000000):
  print(-1)
else:
  print(res)

Submission status: Runtime Error

Solution code:
#B
n = int(input())
a = tuple(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
result = reduce(lambda ans, x:ans * x, a)
if result > MAX:
    flg = False
        

if flg:
    print(result)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(input()) for _ in range(N)]
B = np.array(A)
V = np.prod(B)
if V<= 10**18:
  return V
elif V>10**18:
  return '-1'

Submission status: Runtime Error

Solution code:
n = int(input());
ans = 1;
for i in range(1,n):
  x = int(input());
  ans = ans*x;
 if(ans>1000000000000000):
  print(-1)
 else:
  print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.array(A, dtype=np.float128)

MAX = pow(10, 18)

ans = A[0]


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

if ans > MAX:
    ans = -1

ans = int(ans)

print(str(ans))

Submission status: Runtime Error

Solution code:
from math import trunc
a,b = input().split()
a = int(a)
b = float(b)

print("{}".format(int(a*b)))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
#output = np.prod(A)
AA=1
for i in range(N+1):
  #print(A[i])
  AA = AA * A[i]
a = pow(10,18)
print(AA if abs(AA) <= a else -1)

Submission status: Runtime Error

Solution code:
res = 1
if 0 in a:
    res = 0
else:
    for i in range(n):
        b = a.pop()
        if b != 1:
            res *= b

            if res > 1000000000000000000:
                res = -1
                break
print(res)

Submission status: Runtime Error

Solution code:
N = int(input())

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

x = functools.reduce(operator.mul, A)
y = 10**18


if x > y:
    print("-1")
else:
    print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

a = [int(x) for x in input().split() if x != "1"]

sum = a[0]

for i in range(1,len(a)):
    sum = sum * a[i]
    if 0 in a:
        sum = 0
        break
    elif sum > 10**18:
        break
    


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

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [int(input()) for _ in range(N)]
B = np.Series(A)
V = np.prod(B)
if V<= 10**18:
  return V
elif V>10**18:
  return '-1'

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())                                                             a=1                                                                          for i in range(0,n)                                                              tmp =int(input())
    if tmp==0:                                                                       ans = 0                                                                      break
    if ans == -1:                                                                    continue
    a = a*tmp                                                                    if(tmp > 1000000000000000000):                                                   ans = -1                                                                                                                                          if ans == -1:                                                                    print(-1)
if(ans==0):                                                                      print(0)                                                                                                                                              print(a)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

a_list = [i for i in input().split()]

print(np.prod(a_list))

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:
import numpy
N = int(input())
ls = input().split()
Mul = numpy.prod(ls)
if Mul < 10**18:
  print(Mul)
else:
  print("-1")

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.array(A, dtype=np.float64)

MAX = pow(10, 18)

ans = A[0]


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

if ans > MAX:
    ans = -1

ans = int(ans)

print(str(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
tmp = 1
for num in A:
    tmp *= num
    if tmp > 1e18:
      break
  
if tmp <= 1e18:
    print(tmp)
elif 0 in tmp:
    print(0)
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.array(A, dtype=np.float128)

MAX = pow(10, 18)

ans = A[0]


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

if ans > MAX:
    ans = -1

ans = int(ans)

print(str(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
An_org = list(map(int, input().split()))
An = sorted(An_org)

def dfs(sum, i) :
    if i == len(An)-1 :
        return sum
   
    s = sum * An[i+1]

    if  s > 10 ** 18 :
        return -1

    return dfs(s, i+1)


print(dfs(An[0],0))

Submission status: Runtime Error

Solution code:
import java.math.*;
import java.util.*;
public class Main
{
        public static void main(String[] args)
        {
            Scanner cin = new Scanner(System.in);
            int T;
            T = cin.nextInt();
            BigInteger t = new BigInteger("1000000000000000000");
            BigInteger an = BigInteger.valueOf(1);
            for(int i = 1;i <= T;i ++)
            {
                int f;
                BigInteger m = cin.nextBigInteger();
                int s = m.compareTo(BigInteger.valueOf(0));
                if (s == 0)
                {
                    an = BigInteger.valueOf(0);
                }
                f = an.compareTo(t);
                if(s != 0 && flag <= 0)
                an = an.multiply(m);
            }
            int k = an.compareTo(t);
            if(k <= 0)
                System.out.println(an);
            else System.out.println("-1\n");
        }
}

Submission status: Runtime Error

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

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

if finish = 0:
    print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Al=np.array(Al)

c=Al.prod()

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

Submission status: Runtime Error

Solution code:
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = []

nums = input().rsplit()

# for i in range(0, N - 1):
#     a = input()
#     if a == 0:
#         print(0)
#         sys.exit(1)
#     nums.append(a)

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except OverflowError:
        print(-1)
        sys.exit(1)

    if accum > limit:
        print(-1)
        sys.exit(1)

print(accum)

Submission status: Runtime Error

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

for a in A:
    product *= a
    if a = 0:
        break

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

Submission status: Runtime Error

Solution code:
import numpy as np
import math
from decimal import Decimal
N = int(input())
A = [Decimal(i) for i in input().split()]
a = np.array(A)
c = a.prod()
if c <= 10**18:
    print(c)
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(e) for e in input().split()]
ans = a[0]
a.pop(0)

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

Submission status: Runtime Error

Solution code:
import decimal

N = int(input())
AList = [decimal.Decimal(element) for element in input().split(" ")]
result = 1

for element in AList:
    result *= element

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

Submission status: Runtime Error

Solution code:
n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans > 10**18+1:
        print(-1)
        exit()
    elif ans == 0:
        print(0)
        exit()
print(int(ans))

Submission status: Runtime Error

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

print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input()
a = a.replace(' ','*')
result = eval(a)
if result > 1000000000000000000:
  print('-1')
else:
  print(result)

Submission status: Runtime Error

Solution code:
import math
import sys

C = int(input())
Lista = list(map(int, input().split()))
ans = 0

if Lista[len(Lista -1)] == 0:
    print('0')
    sys.exit()
    
for i in range(C):
    if i == 0:
        ans = Lista[i]
    else:
        ans = ans * Lista[i]
    if ans > 10 ** 18:
        print('-1')
        sys.exit()

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

Submission status: Runtime Error

Solution code:
import sys
N=int(input())
A=list(map(int,input().split()))
x=1
for i in A:
  x*=i
  if x>1000000000000000000:
  print('-1')
  sys.exit()
print(x)

Submission status: Runtime Error

Solution code:
a, b = map(float, input().split())
print(int(a * b))
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= x
    if res > 10**18:
        res = -1
print(res)

Submission status: Runtime Error

Solution code:
import numpy as np

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

# for i in range(0, n):
#     result = result * a[i]

result = np.prod(a)

if result > pow(10, 18):
    result = -1

print(a)
print(result)

Submission status: Runtime Error

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

m = 0
i = 1
for m in range(n):
  i == i*int(a[m])
  m += 1

i == abs(i)

if len(i)>17 and i != 10**18:
  print(-1)
else:
  print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(raw_input())
lst = list(map(int, raw_input().strip().split()))[:n]
mx = 1000000000000000000
if 0 in lst:
    print(0)
else:
    cur = lst[0]
    for x in lst[1:]:
        cur = cur * x
        if cur > mx:
            cur = -1
            break
    print(cur)

Submission status: Runtime Error

Solution code:

a=int(input())
li = list(map(int,input().split()))
if 0 in li:
  print(0)
  
else:
  result = 1
  for number in li:
    result = result * number
    if result > 10**18:
      print(-1)
      break

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

Submission status: Runtime Error

Solution code:
n = int(input())
prod=1
for i in range(n):
    x = int(input())
    if prod*x>1e18:
        prod=-1
        break
    else:
        prod *= x
        
print(prod)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

    vector<ll> a(n);

    bool  flag = true;
    rep(i, n)  {
        cin >> a[i];
        if(a[i]==0) flag = false;
    }
    if(!flag) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    ll tmp = 1e18;

    rep(i, n) {
        ans *= a[i];
        tmp /= a[i];
        if(tmp == 0) {
            cout << -1 << endl;
            return 0;
        }
    }


    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

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

Al=np.array(Al)

c=Al.prod()

if abs(c)>pow(10,18):
    print(-1)
else:
    print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= 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()))
import numpy as np
B = np.array(A,dtype='float64')
ans = np.cumprod(B)
if ans[N-1] > 10**18:
    print(-1)
else:
    print(int(ans[N-1]))

Submission status: Runtime Error

Solution code:
n = int(input())
lis = []
lis.append(list(map(int, input().split())))
ans = lis[0][0]
for i in range(n):
  ans = ans*lis[0][i+1]
if ans <= 1000000000000000000:
  print(ans)
else:
  print('-1')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
 
def input():
    return sys.stdin.readline().strip()
 
n = int(input())
A = list(map(int, input().split()))
sum = 1
for i in range(n):
    sum *= A[i]
if(sum > 10**18):
    sum = -1
print(sum)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
a = list(map(int ,input().split()))
p = np.prod(a)
if(len(p)<=19):
    print(-1)
else:
    print(p)

Submission status: Runtime Error

Solution code:
N = int(input())
L = map(int, input().split())
K = 1000000000000000000
prod = 1
i=0
while(i<N):
  prod *= L[i]
  i = i + 1
  if prod>K:
    break
if prod<=K:
  print(prod)

Submission status: Runtime Error

Solution code:
import numpy as np
input()
input2 = input()
A_array = np.array([np.double(digit) for digit in input2.split(" ")])
product = np.cumprod(A_array)[-1]
if product > 10 ** 18:
  print(-1)
else:
  print(int(product))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import functools
import operator

N = int(input())

a = list()
for _ in range(N):
    a.append(input())
    
    
    result = functools.reduce(operator.mul, a)
    
    if result > 10**18
    print('-1')
    else:
      print(result)

Submission status: Runtime Error

Solution code:
n = int(input())

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

for i in range(0, n):
  product = a[i]*a[i+1]
  
if (product > 10**18):
   print(-1)
else:
   print(product)

Submission status: Runtime Error

Solution code:
N = int(input())
A = sorted(map(int, input().split()))
sum = 1
'''
for i in range(N):
    sum = sum * A[i]  
    
if sum > 10**18:
    print(-1)
else:
    print(sum)   
'''
def suq(A, N):# n = 1
    if N == 0:
        return A[0]
    else:
        return A[N] * suq(A, N-1)
        print(N)

sum = suq(A, N-1)
if N == 2:
    print(A[0] * A[1])
else:    
    if sum > 10**18:
        print(-1)
    else:
        print(sum)

Submission status: Runtime Error

Solution code:
A,B  = map(float, input().split())
print(int(A * B))
N = int(input())
lst = list(map(int, input().split()))
res = 1
if 0 in lst:
    res = 0
for x in lst:
    res *= x
    if res > 10**18:
        res = -1
print(res)

Submission status: Runtime Error

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

print(b, end='')

Submission status: Runtime Error

Solution code:
A,B = list(input().split())

fl = float(A)*float(B)
st = str(fl)
ans ,tr = st.split(".")

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    n = int(stdin.readline())
    a = list(map(int,stdin.readline().split()))
    f = 1
    flag=0
    a = sorted(a)
    for i in range(n):
        f = f*a[i]
        if f>10**18:
            flag=1
            break
    if flag:
        print("-1")
    else:
        print(f)

main()

Submission status: Runtime Error

Solution code:
n=eval(input())
ans=1
f=0
for i in range(n):
  x=eval(input())
  ans=ans*x
  if x==0:
    f=1
if f==1:
  print("0")
else :
  if(ans>1000000000000000000 or ans<0):
    print("-1")
  else:
    print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=1
a=list(map(int,input().split()))
m=n-a.count(1)
b=sorted(a)
c=list(set(b))
if (1 in b)and(len(c)>1):
    if c[1]==1: 
        del b[:b.index(c[2])-1]
    else:
        del b[:b.index(c[1])-1]
for i in range(n):
    ans*=b[i]
    if 0 in a:
        ans=0
        break
    if m>68:
        ans=-1
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Submission status: Runtime Error

Solution code:
from math import log10
import numpy as np

def main(N):
    ans = np.prod(np.array(list(map(int, input().split()))))
    if log10(ans) >= 18 and ans != 10 ** 18:
        print(-1)
    else:
        print(ans)





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

Submission status: Runtime Error

Solution code:
count = input()
list = input().split(" ")

i = 0
num = int(list[i])
i += 1
while i>= count:
  num = num * int(list[i])
	
  if num > 10**18:
    print(-1)
    break
    
  i += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
input()
input2 = input()
A_array = np.array([float(digit) for digit in input2.split(" ")])
product = int(np.cumprod(A_array)[-1])
if product > 10 ** 18:
  print(-1)
else:
  print(int(product))

Submission status: Runtime Error

Solution code:
import math

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

s = 0


for i in A:
    t = math.log10(i)
    s += t
    print(s)

if s > 18:
    print(-1)
    exit(0)
else:
    for h in A :
        ans *= h
print(ans)

Submission status: Runtime Error

Solution code:
m = int(input())
s = [int(input()) for i in range(m)]
ans=1
for i in s:
    ans*=i
    if ans >= 10**18:
        ans=-1
        break
print(ans)

Submission status: Runtime Error

Solution code:
open Batteries
let n = read_int ()
let a = read_line () 
let a2 = a |> String.split_on_char ' ' |> List.map int_of_string
let rec loop lst r=
  match lst with
  | [] -> r
  | first :: rest ->
    if List.mem 0 a2 then 0 else
    if first <> 1 && 1000000000000000000 / 2 <= r then -1 else
    loop rest (r*first)

let l = loop a2 1
let _ = l |> Printf.printf "%d\n"

Submission status: Runtime Error

Solution code:
import sys

n=input()
a=list(map(int,input().split()))
Limit = 10**18

Ans = 1
for i in a:
    Ans = Ans*i
    if Ans > Limit:
        print(-1)
        sys.exit(-1)

print(Ans)

Submission status: Runtime Error

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

lim = 10**18
if len(B[B==0]) >0:
    print(0)
elif N >59:
    print(-1)
else:
    ans = 1
    for i in A:
        ans *= i
        if ans > lim:
            print(-1)
            exit()
    else:
        if ans >10**18:
            print(-1)
        else:
            print(ans)