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:
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:
import numpy as np
N = int(input())
A =list(map(np.float128, input().split(" ")))
ret = np.prod(A)
ret = int(ret)

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())
lst = list(map(int,input().split())
output = 1
if 0 in lst :
	print(0)
    quit()
for x in lst :
	output = output * x           
    if output > 10**8 :
    	print(-1)
        quit()
print(output)

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

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

Submission status: Runtime Error

Solution code:
N = int(input())

num_list = list(map(int, input().split()))
     
num = 1
     
for i in num_list:
    num *= i
    
    if num == 0:
        break

if num > 1000000000000000000:
    num = -1
    break

print(num)

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

Submission status: Runtime Error

Solution code:
n = int(input())
prod = 1
a = []
for i in range(n):
    a.append(int(input()))
sorted(a)
if(a[0]==0):
	print(0)
for i in range(n):
	prod*=a[i]
	if(prod>1e18):
		print(-1)
		return
print(prod)

Submission status: Runtime Error

Solution code:
from numba import njit
N = int(input())
a = list(map(int, input().split()))
@njit()
def main():
  b = 1
  for i in range(N):
    b *= a[i]
    if 0 in a:
      b = 0
      break
    elif b > 10 ** 18:
      b = 'out'
      break
  if b == 'out':
    print(-1)
  else:
    print(b)
main()

Submission status: Runtime Error

Solution code:
n = input(); n=1
X = str(input())
em = 0
for spam in range(len(X)):
    if X[spam] == " ":
        n *= int(X[em:spam])
        em = spam+1
    if len(str(n-1)) >= 19:break
n *= int(X[em:])
if len(str(n-1)) >= 19:
    print(-1)
else:
    print(n)

Submission status: Runtime Error

Solution code:
import numpy as np

from decimal import Decimal

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

ans = Decimal("1")

for i in a:
    ans *= Decimal(i)

#print(ans - Decimal("1000000000000000000"))

if(ans - Decimal("1000000000000000000") > 0):
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
lt = [int(x) for x in input().split()]
if 0 in lt:
    print(0)
else:
    ans = 1 
    for x in lt:
      ans*=x 
      if ans > 10**18:
        ans='-1'
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    A = np.array(list(map(int, input().split())))
    limit = 10 ** 18

    if np.any(A == 0):
        print(0)
    elif np.any(A > limit):
        print(-1)
    else:
        ans = 1

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

        print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
import sys

over = 10**8

n = int(input())
a = list(map(int, input().split()))
ans = 1;
for i in range(n):
  ans = ans * a[i]
  if ans > over:
    ans = -1
if ans < 0:
  print(-1)
else:
  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:
        print(-1)
    else:
        print(ans)





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

Submission status: Runtime Error

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

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= A[i]
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)

Submission status: Runtime Error

Solution code:
n = int(input())
s = raw_input().split(' ')
res = 1
for i in s:
    res *= int(i)
if res > 1e18:
    print('-1')
else:
    print(res)

Submission status: Runtime Error

Solution code:
n = int(input())

sum = 0
i = 0

for i in range(n):
  x = int(input())
  sum *= x
  i += 1
  print(sum)
  
  if sum > 10 ** 18:
    print(-1)
    break

Submission status: Runtime Error

Solution code:
N, result = eval(input()), 1
List = list(map(int, input().split()))
if 0 in List:
  print(0)
  quit()
for i in List[N]:
    result *= i
    
print(result if result <= 10**18 else -1)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
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:
a=int(input())
b=input().split(' ')
m=0
s=1
j=0
while m<a:
	if b[m]==0:
        print(0)
        j=j+1

    m=m+1

m=0
while m<a and j==0:
    s=s*int(b[m])
    if s>10**18:
		print(-1)

    m=m+1


else:
    print(s)

Submission status: Runtime Error

Solution code:
import sys
inp = list(map(str,input().split()))
a = int(inp[0])
b = float(inp[1])
#print(a)
#print(b)
bb = int(b * 100)
print(int(a * bb / 100))
#prod = 1
#overflow = False
#
#a = list(map(int,input().split()))
#
#for aa in a:
#  if prod * aa > 1000000 * 1000000 * 1000000:
#    overflow = True
#  else:
#    prod = prod * aa
#
#for aa in a:
#  if aa == 0:
#    overflow = False
#
#if overflow:
#  print(-1)
#else:
#  print(prod)

Submission status: Runtime Error

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

ans =1

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

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

Submission status: Runtime Error

Solution code:
# from operator import mul
# from functools import reduce

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

# ans = 1
# ans = reduce(mul, a) #=> 1320

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

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

Submission status: Runtime Error

Solution code:
N, result = eval(input()), 1
List = list(map(int, input().split()))
for i in List[N]:
    result *= i
    
print(result if result <= 10**18 else -1)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
 
ans = a[0]*a[1]
if n != 2:
  for i in range(n-2):
    ans *= a[i+2]
else:
  continue
if ans > 1e18:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in range(a):
  ans *= a[i]
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Submission status: Runtime Error

Solution code:
def main(n, a):
  for x in a:
    if(x == 0):
      print(0)
      return
   
  ans = a[0]
  for i in range(1, n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
      print(-1)
      return
  print(ans)
 
if(__name__ == '__main__'):
  n = int(input())
  a = map(int, input().split())
  main(n, a)

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:
N = int(input())
A = [int(x) for x in input().split()]

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= a
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)

Submission status: Runtime Error

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

m=0
while m<a and j==0:
    s=s*int(b[m])
    if s>10**18:
		print(-1)
    
    m=m+1


else:
    print(s)

Submission status: Runtime Error

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

ans = 1

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

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


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

Submission status: Runtime Error

Solution code:
n=int(input())
lis=list(map(int, input().split()))
if 0 in lis:
  print(0)
  exit()
elif max(lis)>10**18:
  print(-1)
  exit()

def calc(i, h):
  if h>=10**18:
    return(-1)
  elif i==0:
    return(h)
  else:
    return h*calc(i-1, lis[i-1])
print(calc(n, 1))

Submission status: Runtime Error

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

n = input()
n_list = [int(i) for i in input().split()]
value = 1
for i in n_list
    value = value * i


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

Submission status: Runtime Error

Solution code:
n = int(input())

ca = 1
for i in range(n):
    a = int(input())
    ca = ca*a

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

print(ca)

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=np.float64)
#print(a_n)
result = np.prod(a_n)
if result >= 10**18:
    print(-1)
else:
    print(int(result))

Submission status: Runtime Error

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

ans = 1

if 0 in A:
    print(0)
    exit:

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


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

Submission status: Runtime Error

Solution code:
from functools import reduce

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

limit = pow(10, 18)

ans = 1.0
for e in nums:
    ans *= e

if ans >= limit:
    ans = -1

print(int(ans))

Submission status: Runtime Error

Solution code:
import  numpy as np

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:

def main(n, a):
  for x in a:
    if(x == 0):
      print(0)
      return
   
  ans = a[0]
  for i in range(1, n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
      print(-1)
      return
  print(ans)

if(__name__ == '__main__') {
  n = int(input())
  a = map(int, input().split())
  main(n, a)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000000000)
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:
lst = []
n = int(input())
for i in range(0,n):
	ele = int(input())
    lst.append(ele)
    
val = 1000000000000000000
ans = 1
for i in range(0,n):
	ans = ans*list[i]
    if(ans > val):
    	ans = -1
        break
print(ans)

Submission status: Runtime Error

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

while len(new_list) > 1:
    new_list = [0]*(len(a)//2 + len(a)%2)
    for i in range(len(new_list)):
       new_list[i] = a[i]*a[i+len(a)//2]
    if len(a)%2 == 1:
      new_list[-1] = a[-1]
    a = new_list
  
if new_list[0] <= 10**(18):
    print(new_list[0])
else:
    print(-1)

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)
if 1 in b: 
    del b[:b.index(2)-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:
import numpy as np

N = int(input())
v = np.arrray(list(map(int, input().split())))

answer = v.prod()

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

Submission status: Runtime Error

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

using namespace std;

unsigned long long int overflow = 1e+18, ip;
long long int res=1;

int main() {
    int n;  cin>>n;
    vector<int> arr;
    int flag=1;
    
    for(int i=0; i<n; i++){
        cin>>ip;
        arr.push_back(ip);
    }
    
    sort(arr.begin(), arr.end());
    
    if(arr[0]==0){
        res = 0;
    }
    else
    for(int i=0; i<n; i++){
        res=arr[i]*res;
        
        if(ip==0){
            res = 0;
            break;
        }
        
        if(res<0 || res>overflow){
            res = -1;
            break;
        }
    }
    
    cout<<res;
    
    return 0;
}

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=np.float64)
#print(a_n)
result = np.prod(a_n)
if result > 10**18:
    print(-1)
else:
    print(int(result))

Submission status: Runtime Error

Solution code:
import math

def main():
  a, b = input().split()
  a = int(a)
  b = float(b)
  c = int(b)
  d = (b - c) * 100
  ans_a = a * c
  ans_b = (a * d) // 100
  ans = math.floor(ans_b) + ans_a
  print(ans)
 
 
if __name__ == '__main__':
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in num:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

Submission status: Runtime Error

Solution code:
from functools import reduce
from operator import mul

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

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

a_li = [a for a in a_li if a != 1 and a != 0]
ans = reduce(mul, a_li)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a_list = list(map(int,input().split()))
import math
result = 0
check = True
for a in a_list:
  if a == 0:
    check = False
    break
  else:
    result += math.log10(a)
if check == False:
  print(0)
elif 10**result > 18:
  print(-1)
else:
  print(int(10**result))

Submission status: Runtime Error

Solution code:
n = int(input())

a = []
for i in range(n):
  t = int(input())
  a.append(t)
ans = 1

for i in range(n):
  ans *= a[i]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import functools
import operator
N=input()
A=map(int,input().split)
A=functools.reduce(operator.mul,A)
if A>10**18:
    A=-1
print(A)

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    list = list(map(int, input().split()))
    no = 0
    non = 0
    ans = 1
    lens = 0
    if (list.count("0") >= 1):
      print("0")
      exit()
    else:
      for i in range(N):
        lens = lens + len(list[non])
        non += 1
        if (lens >= 19):
          print("-1")
          exit()
        else:
          for j in range(N):
            ans = ans * list[no]
            no += 1
            print(ans)
resolve()

Submission status: Runtime Error

Solution code:
m = int(input())
s = [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:
import math
N = int(input())
list=[]
for i in range(N):
    i = int(input())
    list.append(i)

if  math.prod(list) < 1000000000000000000:
    print(math.prod(list))
else:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print (int(A*B))

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
n = input()
num_list = [float(i) for i in n.split()]
num_list = np.array(num_list,dtype=np.float128)
m = np.prod(num_list,axis=0)
if(m > 1e+18):
  print(-1)
else:
  print(int(m))

Submission status: Runtime Error

Solution code:
N=int(input())
A=[list(map(int,list(input()))) for i in range(N)]

s=1
for i in range(N):
    s = s*A[i]
    if s > 10**18:
        s = -1
        print('-1')
        break
if s != -1:
    print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
if N>=2 and N<=10**5:
    array=list(map(int,input().strip().split()))
    if range(array)==N:
        if array[0]>=0 and array[-1]<=10**18:
            multipul=1
            for i in len(array-1):
                multipul=multipul*array[i]
            print(multipul)

Submission status: Runtime Error

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

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 i in range(n):
    if len(str(ans))>=19:
      ans='-1'
      break
    else:
      ans*=a[i]
if ans>10**18:
  ans='-1'
print(ans)

Submission status: Runtime Error

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


t= False

for i in a:
    if i==0:
        print(0)
        t = true
ans = 1
end = 10**18
if not t:
    for i in a:
        ans *= i
        if ans > end:
            t = True
            break
    if t:
        print(-1)
    else:
        print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

sum = 0
i = 0

for i in range(n):
  x = int(input())
  sum *= x
  i += 1
  
  if sum > 10 ** 18:
    print(-1)
    break
    
print(sum)

Submission status: Runtime Error

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

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):
    if N == 1:
        return 1
    else:
        return A[N-1] * suq(A, N-1)

if suq(A, N) > 10**18:
    print(-1)
else:
    print(suq(A,N))

Submission status: Runtime Error

Solution code:
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)

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)
del b[:a.index(2)-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:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range (0, N):
	if A[i] == 0:
		ans = 0
		break
	else:
		if ans > 0
        	ans *= A[i]
		if ans > 10 ** 18:
			ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    double sr;
    long long int lr;
    cin >> lr >> sr;

    cout << (long long int)(double(lr%1000) * sr)+(lr/1000)*((long long int)(sr*1000)) << endl;
}

Submission status: Runtime Error

Solution code:
n = int(input())
result = 1
a = list(map(int,inputt().split()))
for ai in a:
    result *= ai
if result > 1000000000000000000:
    print("-1")
else:
    print(result)

Submission status: Runtime Error

Solution code:
MAX = 10**18
def main():
    N = map(int,input())
    A = list(map(int,input().split(' ')))
    ans = 1
    for a in A:
        if a == 0:
            print(0)
            exit(1)
        ans *= a

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(1,18):
            if a <= 10**j:
                m = j
                break
        for k in range(1,18):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 18):
            print(-1)
            break
        elif(m+n == 18 and ans*a == 10**18):
            ans = ans*a
        elif(m+n == 18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Submission status: Runtime Error

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

sum = 1
for i in a:
  sum = sum * int(i)

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

Submission status: Runtime Error

Solution code:

// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sc scanf
#define pr printf

#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sqr(x) ((x) * (x))

#define sci(n) sc("%d", &n);
#define sci2(n, m) sc("%d%d", &n, &m);
#define scl(n) sc("%I64d", &n);
#define scl2(n, m) sc("%I64d%I64d", &n, &m);

#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1000000000;
const ull mx = 1000000000000000000ll;

int main() {
	TEZ;

	int n;
	cin >> n;

	ull t;
	ull p = 1;
	ll jv;
	while (n--) {
		cin >> t;

		if (log10(p) + log10(t) + 2 >= 19)
			jv = -1;
		else
			p *= t;
	}

	if (jv == -1 && p != 0)
		cout << -1 << endl;
	else
		cout << p << endl;

	return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
lst = list(map(int, input().split()))
output = 1
if 0 in lst:
    print(0)
    quit()
for x in lst:
    output = output * x
    if res > 10**18:
        print(-1)
        quit()
print(output)

Submission status: Runtime Error

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

int main() {
  int N;
  cin >> N;
  vector<int> vals(N);
  for (int i = 0; i < N;i++){
    cin >> vals.at(i);
  }
  int prod = std::accumulate(vals.begin(), vals.end(), 1, [](int init, int v) { return init * v; });
  if (prod > pow(10, 18)){
    cout << "-1" << endl;
  }
  else cout << prod << endl;
}

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
n = input()
num_list = [int(i) for i in n.split()]
num_list = np.array(num_list,dtype=np.float128)

m = np.prod(num_list,axis=0)
if(m > 1e+18):
  print(-1)
else:
  print(int(m))

Submission status: Runtime Error

Solution code:
import math

a, b = input().split()
print(math.floor(int(a) * float(b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
lis=list(map(int, input().split()))
if 0 in lis:
  print(0)
  exit()
elif max(lis)>10**18:
  print(-1)
  exit()

def calc(i, y):
  if i==n-1:
    return y
  elif y>10**18:
    return "-1"
  else:
    return calc(i+1, lis[i+1])*y
result=calc(0, lis[0])

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
 
 
long long LIMIT = 1000000000000000000;
 
int main(){
  int n;
  cin >> n;
  vector<long long> vec(n);
  
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  if ( std::find(vec.begin(), vec.end(), 0) != vec.end() ) {
    cout << 0 << endl;
    return 0;
  }
  
  long long products = 1;
  for (int i = 0; i < n; i++) {
    products *= vec.at(i);
	if(products > LIMIT) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << products << endl;
  
  return 0;

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import operator as op
n=int(input())
a=list(map(int,input().split()))
ans=reduce(operator.mul,a,1)
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


def multiplyList(myList):
    result = 1
    for x in myList:
        result = result * x
    if results <= 1000000000000000000:
        return result
    else:
        return -1


print(multiplyList(results))

Submission status: Runtime Error

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

maxn = 1000000000000000000

if a * b > maxn:
  print (-1)
else:
  print (a * b)