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: Wrong Answer

Solution code:
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
flag1=0
for i in range(n):
    if a[i]==0:
        x*=0
        flag1=1
        break
if flag!=1: 
    for i in range(n):
        if x>1000000000000000000:
            flag=1
        else:
            x*=a[i]
        
if flag1==1:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

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

    
    
    
print(a)

Submission status: Wrong Answer

Solution code:
import functools
import operator
n=int(input())
li = list(map(int, input().split()))
if (len(li)<=80):
    result = functools.reduce(operator.mul, li)
    if (result > (1000000000000000000)):
        print(-1)
    else:
        print(result)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def multiplyList(l): 
    result = 1
    for x in l: 
        result = result * x 
        if(result > 1000000000000000000):
        	return "-1"
    return result 

t=int(input())
l=list(map(int,input().split()))
n = multiplyList(l)
print(n)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(float ,input().split()))
p = np.prod(a)

if len(str(p))>=19:
    print("-1")
else:
    print(p)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N <= 2:
    A = map(int, input().split())
    re = 1
    for i in A:
        re *= i
    if re > 10**18:
        print(-1)
    else:
        print(re)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
import numpy as np

N = int(input())

sums = 1;
string = input().split()

candis = []
for i in range(N):
    candis.append(int(string[i]))


candis = np.sort(np.array(candis))

if(candis[0] == 0):
    print(-1)
    exit()
    
for i in range(N):
    sums = sums * candis[candis.size - i - 1]
    if(sums > pow(10,18)):
        print(-1)
        exit()
print(sums)

Submission status: Wrong Answer

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

mul = 1
for i in l:
    mul *= i
    if(mul>=10**18):break
    
if(mul>10**18):print(-1)
else:print(mul)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
count = input()
lst = list(map(int, input().split()))
result = 1
for item in lst:
    result = result * item
    if (result > pow(10, 18)):
        print(-1)
        exit(0)
print(result)

Submission status: Wrong Answer

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

for i in range(0,len(b)):
    b[i]=int(b[i])



res=1
state=1
for i in range(0,len(b)):
    res*=b[i]
    if res==0:
        print(res)
        state=0
        break
    if res>1000000000000000000:
        print("-1")
        state=0
        break
    if (len(b)-1)==i:
        print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np;
from numba import jit
import warnings
warnings.simplefilter('ignore')

@jit
def slove(ans, A):
    for a in A:
        if a > 10 ** 18:
            return -1
        ans *= a
    return ans



if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = slove(1, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Wrong Answer

Solution code:
N= int(input())
lists = list(map(int,input().split()))
import math
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
#print( math.log(q, 10))
if q-10**18>=0:
    print(-1)
else:
    print(q)

Submission status: Wrong Answer

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

mul=1
i=0

if '0' in p:
  print(0)
else:
  while mul<=100000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>100000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

Submission status: Wrong Answer

Solution code:
n = int(input())

a_list = [int(i) for i in input().split()]
result = 1
for a in a_list:
    result *= a
if result > 1 + 10 ** 18:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
p=1
flag=0
for i in range(n):
    if p>10**18:
        flag=1
        break
    else:
        p*=l[i]
if flag==0 and p<=10**18 :
  print(p)
else:
  print(-1)

Submission status: Wrong Answer

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

ans = 1
over = 10**18

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np;
from numba import jit
import warnings
warnings.simplefilter('ignore')

@jit
def slove(ans, A):
    for a in A:
        if ans > 10 ** 18:
            return -1
        ans *= a
    return ans



if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = slove(1, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
S = list(map(int, input().split()))
ans = np.prod(S)
if ans > 10 ** 18:
  nans = -1
else:
  nans = ans
print(nans)

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='object')
    ans = np.prod(A[0:N])
    print(np.iinfo(np.int64))
    if ans > 10**18:
        print('-1\n')
    else:
        print(f'{ans}\n')
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in numbers:
    print(0)
for n in numbers:
    mlt *= n
    if mlt > 1000000000000000000:
        mlt = -1
        break
print(mlt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mul = 1
for i in l:
    mul *= i
    if(mul>10**18):break
    
if(mul>10**18):print(-1)
else:print(mul)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
ans=1
if len(a)<90:
    for i in range(len(a)):
        ans*=a[i]

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import numpy as np

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

if 0 in aa:
    print(0)
    sys.exit()

a = [s for s in aa if s != 1]
a.sort(reverse=True)

keta = 0
for item in a:
    k = len(str(item))
    keta += k-1
    if keta>18:
        print(-1)
        sys.exit()

arr = np.array(a)
ans = arr.prod()
if ans>10**18:
    print(-1)
    sys.exit()

print(ans)

Submission status: Wrong Answer

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

ans = 1

a.sort(reverse=True)

for x in range(n):
    if 0 in a:
        ans = 0
        break

    ans *= a[x] % 1000000007

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


print(ans)

Submission status: Wrong Answer

Solution code:
import functools
import operator

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import numpy as np
N = int(input())
li = list(map(int, input().split()))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
a = np.prod(a)
print(int(a) if a <= 10**18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
p=1
flag=0
for i in range(n):
    if p>10**18:
        flag=1
        break
    else:
        p*=l[i]
if flag==0 and p<10**18 :
  print(p)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
num=int(input())
num1=int((num-num%2)/2)
date0=input().rstrip().split(" ")
date0=sorted(date0)
sum=1
if int(date0[0])==0:
    print(0)
else:
    for i in range(num1):
        sum=sum*int(date0[i])
    if sum>10**18:
        print(-1)
    else:
        for i in range(num-num1+1):
            sum=sum*int(date0[i])
        if sum>10**18:
            print(-1)
        else:
            print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=input()
a=list(map(int,input().split()))
a=np.array(a,dtype="uint64")
ans=np.prod(a)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
x = list(map(int, input().split()))

npx = np.array(x)
ans = np.prod(npx)
if ans>pow(10,18):
  ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(s)
np.sort(a)
num = 1

for i in range(n):
  num = a[i-1] * num

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())

if n >= 100:
    print(-1)
    exit()

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

ans = a.prod()

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
ans = np.array(list(map(int, input().split()))).prod()

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

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
r = list(map(int,input().split()))

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x > lim:
        x = -1
        break

print(int(x))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = np.prod(num)
no = -1
ans = int(product)
if ans > 10**18:
    print(no)
else:
    print(ans)

Submission status: Wrong Answer

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

import numpy as np
ans = np.prod(a)
if ans <= 10**18:
    print(ans)
else:
    print('1')

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
s=list(map(int, input().split()))
p = np.prod(s)
print(-1 if p>10**18 else p)

Submission status: Wrong Answer

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

mul=1
i=0

if '0' in p:
  print(0)
else:
  while mul<=100000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if i!=n:
    print(-1)
  else:
    print(mul)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul
import sys
input = sys.stdin.readline

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
if 0 in list:
    print(0)
else:
    for i in range(count - 1):
        sum = sum * list[i + 1]
    if sum > 1000000000000000000:
        print(-1)
        exit()


print(sum)

Submission status: Wrong Answer

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



x=np.prod(a)

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

Submission status: Wrong Answer

Solution code:
m = int(input())
n = input().split()
s=[]
for i in n:
    s.append(int(i))
sorted(s)
ans=1
for i in s:
    ans*=i
    if ans==0:
        break
    elif ans >= 10**18:
        ans=-1
        break
    else:
        ans=-1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = np.prod(num)
no = "-1"
ans = int(product)
if ans > 10**18:
    print(no)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = 1
over = 10**18

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

print(ans)

Submission status: Wrong Answer

Solution code:
sute = input()
input_nums = input().split()

output = 1


for num in input_nums:
    output *= int(num)   
    if output > 10^18:
        output = -1

if output <= -1:
    output = -1


print(output)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
while(n>i):
	ans*=p[i]
	n-=1
	if(p[i]==0):
		break
	if(ans>1000000000000000000):
		break
	i+=1		
if(ans>1000000000000000000):
		print(-1)
else:
		print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

Alist = []
A = input()
A = A.split()
for a in A:
    Alist.append(int(a))

def program():
    ans = 1
    for a in Alist:
        ans *= a
        if ans > 10**18:
            return -1
    return ans

print(program())

Submission status: Wrong Answer

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

for i in range(N):
    multiple = multiple * A[i]
    if (multiple > 18 ** 10) or(multiple==0):
        break
    
if multiple > 10 ** 18:
    print('-1')
else:
    print(multiple)

Submission status: Wrong Answer

Solution code:
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 


for i in range(N):
    #if(res*2 > MAX):
    #    print(-1)
    #    exit(0)
    res *= liste[i]
    if(res > MAX):
        print(-1)
        exit(0)

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

Submission status: Wrong Answer

Solution code:
from decimal import *
def resolve():
    N = int(input())
    A = list(map(Decimal,input().split()))
    ans = Decimal(1)
    if N > 59:
        print(-1)
    elif 0 in A:
        print(0)
    else:
        for i in range(N):
            ans = A[i] * ans
            if ans > 10**18:
                break
        if ans > 10**18:
            print(-1)
        else:
            print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
mark = False
if 0 in a:
    print(0)
    mark = True
if mark==False:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            mark = True
            print(-1)
        break
if not mark: print(ans)

Submission status: Wrong Answer

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

product = 1
for a in A:
    product *= a
    if a == 0:
        break
    if product <= 10**18:
        product = -1
        break

print(product)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)-1):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
 
num_list = input().split()
 
total = int(1)
if "0" in num_list:
  print(0)
  
else:
  for i in range(N):
    if len(str(total)) >= 19:
      break
    else:
      total *= int(num_list[i])
  if len(str(total)) >= 19:
    print(-1)
  else:
    print(total)

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
error = -1
for j in nums:
    ans = ans * j
if(len(str(ans)) > 18):
    print(error)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys


try:
    sys.stdin = open(sys.path[0] + '/input.txt', 'r')
    sys.stdout = open(sys.path[0] + '/output.txt', 'w')
except FileNotFoundError:
    pass


def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    
    res = 1
    for num in arr:
        res *= num
        if res > 10 ** 18:
            return -1
    
    return res


print(solve())

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
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')
        k=N
if c<10**18:
      print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())

a = list(input().split())
a = [int(i) for i in a]
ans=1

if len(a) % 2 == 1: 
  for i in range(1, int(len(a)/2)+2):
    if ans > 10**18 or ans == 0:
      break

    if i == int(len(a)/i) + 1:
      ans = ans*a[i-1]
    else:
      ans = ans*a[i-1]*a[-1*i]
    
else:
  for i in range(0, int(len(a)/2)):
    if ans > 10**18 or ans == 0:
      break
    ans = ans*a[i]*a[-1 - i]
    

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

Submission status: Wrong Answer

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


for i in range(n):
    if 0 in a:
        f = 0
        break
    elif f <= 10 ** 18:
        f = -1
        break
    else:
        f *= a[i]
  
 
if f > 10**18:
    print(-1)
else:
    print(f)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    n = int(input())
    limit = pow(10,18)
    readStr = input()
    flds = readStr.split(" ")
    res = 1
    for i in range(n):
        if flds[i] == 0:
            res = 0
            break
        res *= int(flds[i])
        if res > limit:
            res = -1
            break
    print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ret = 1
    for a in A:
        ret *= a
        if ret > limit:
            print(-1)
            return None
    print(ret)



if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
a = np.prod(a)
print(a if a <= 10**18 else -1)

Submission status: Wrong Answer

Solution code:
import math

kosuu = int(input())
arr = list(map(int, input().split()))

hoge =1
for num in arr:
    hoge = hoge*num
    if hoge==0 and hoge>1000000000000000000:
        if hoge==0:
            print(0)
            kosuu=0
            break
        else:
            print(-1)
            kosuu=0
            break
if kosuu>0:
    print(hoge)

Submission status: Wrong Answer

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

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        break
    elif s > 0:
        s *= mlist[i]

    if s >= 10**18:
        s = -1
if i == N-1:
    print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import functools
import operator
n=int(input())
li = list(map(int, input().split()))
if (len(li)<=80):
    result = functools.reduce(operator.mul, li)
    print(result)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
INF = 10 **18
N= int(input())
ans =1
A= list(map(int,input().split()))
# if 0 in A:
#     print(0)
# else:
def calc(A):
    ans = -1
    for  a in A:
        if ans == -1:
            ans = a
        elif ans == 0:
            return 0
        else:
            ans *= a
        if ans > INF:
            # print(-1)
            return '-1'
    return ans

# ans = np.prod(A)
# ans = -1 if ans > INF else ans
print(calc(A))

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import numpy as np

N = int(input())
s = input().split()
k = [int(_) for _ in s]
p = np.prod(k)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

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

thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))

Submission status: Wrong Answer

Solution code:
N = int(input())

Alist = []
A = input()
A = A.split()
for a in A:
    Alist.append(int(a))

def program():
    ans = 1
    for a in Alist:
        ans *= a
        if ans > 10**18:
            return "-1"
    return ans

print(program())

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
w=pow(10,18)
p=1
for k in range(n):
  p*=a[k]
print(p) if p<w else print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce
from operator import mul

input_number = int(input())
b = list(map(int, input().split()))

ans = reduce(mul, b)
if ans > np.uint64(10 ** 18):
    ans = -1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


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

    ans = A[0]
    if 0 in A:
        print(0)
        return

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

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

    print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout 

n = stdin.readline() 
arr = [int(x) for x in stdin.readline().split()] 

mult = 1;

for x in arr:
	mult *= x;

if(mult < 1000000000000000001):
	stdout.write(str(x))
else:
	stdout.write("-1")

Submission status: Wrong Answer

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

a.sort()

if a[0] == 0:
        print(0)
        exit(0)

ans = 1
for i in a:
        ans *= i
        print(i, ans)
        if (ans > 1e18):
                print(-1)
                exit(0)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
b=0
s=1
for i in range(n):
  b = b + len(str(a[i])) -1
  if b > 18:
    s=-1
    break
  elif a[i]==0:
    s=0
    break
  else:
    s=s*a[i]

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

Submission status: Wrong Answer

Solution code:
import functools
import operator
n=int(input())
li = list(map(int, input().split()))
if (len(li)<=65):
    result = functools.reduce(operator.mul, li)
    print(result)    
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ret = 1
    for a in A:
        ret *= a
        if ret > limit:
            print('-1')
            return None
    print(ret)



if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
a_r = sorted(a, reverse=True)

ans = 1
for x in a_r:
  ans = ans * x
  if ans > 1000000000000000000:
    print(-1)
    exit(0)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=np.prod(a)
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if flag:
  print(ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A_list = list(map(int,input().split()))
#print(A_list)

answer = 1
i_0 = 0.
for a in A_list:
    if a == 0:
        answer=0
        i_0=0.
        break
    else:
        answer *= a
        i_0 += math.log10(float(a))

if i_0>=18:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
MAX = 10 ** 18
n = input()
A = list(map(int, input().split()))
total = 1
for a in A:
  total *= a
  if total > MAX:
    total = -1
    break
print(total)

Submission status: Wrong Answer

Solution code:

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


for i in range(n):
    if 0 in a:
        f = 0
        break
    elif f <= 10 ** 18:
        break
    else:
        f *= a[i]
  
 
if f > 10**18:
    print(-1)
else:
    print(f)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if 0 in A:
    print('0')
elif A.prod() > 1000000000000000000 or A.prod() < 0:
    print('-1')
else:
    print(int(A.prod()))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int,input().split()))
c = str(b)
n = 1
m = 1

if c.count('0') != 0:
  print(0)
  exit()
  
aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  if n > 10**18:
    break
  
for i in range(int(aa),a):
    m *= b[i]
    if m > 10**18:
      break

if n * m <= 10**18:
    print(n*m)
    exit()
  
print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = 1

for a in A:
    s = s * int(a)

if s < 1000000000000000000:
    print(s)
else:
    print("-1")