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:
# Sつの文字入力
S = input()

#数字入力
N =input()

# スペースで区切り処理
inputs = N.split(' ')

# 最終的結果の数字
final = int(1)

#配列inputsの中身をstrからintに変換する
intlist = list(map(int, inputs))
tint_list = tuple(intlist)

#Nの数字をnumberに1つずつ代入し全て掛け算して結果をfinalに代入する

for number in tint_list:
 final = final * number

print(final)

#finalが10の18乗を超えていたら'-1'を出力する
#超えていなければfinal(計算した値)を出力する

if final > 1000000000000000000 :
    print('-1')
elif final <= 1000000000000000000 :
    print(final)

Submission status: Wrong Answer

Solution code:
_, *a = map(int, open(0).read().split())
ret = 1
for x in a:
  ret *= x
  if ret > 10**18:
    ret = -1
    break
print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A_n = list(map(int, input().split(' ')))
total = np.prod(A_n)
if total <= 10 ** 18:
    print(np.prod(A_n))
else:
    print('-1')

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:
#!/usr/bin/env python3

import numpy as np


def main():
    input()
    A = np.fromstring(input(), np.int64, sep=' ')
    ans = np.prod(A, axis=0)
    if ans <= 10 ** 18:
        print(ans)
    else:
        print('-1')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

U = 10 ** 18
p = 1
for x in A:
    p *= x
    if p > U:
        p = U + 1

if p > U:
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

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

import numpy as np


def main():
    input()
    A = np.array(list(map(int, input().split())), np.int64)
    ans = np.prod(A, axis=0)
    if ans <= 10 ** 18:
        print(ans)
    else:
        print('-1')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print (0)
        return

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

main ()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
li = [int(x) for x in input().split()]

ans = np.prod(li)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
from itertools import accumulate
def main():
    t = 10**18
    n = int(input())
    A=[int(i) for i in input().split()]
    tmp = 1
    for i in A:
        tmp*=i

    if tmp>t:print(t)
    else:print(tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
t=1;print([t:=(t:=t*int(a),-1)[t<0|t>1e18]for a in[*open(0)][1].split()][-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

  if 0 in A:
    print(0)
    return

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

  print(p)
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

for A in arg:
  m = A * m
  if m > 1000000000000000000:
    m = -1
    break;

print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
list = input().split(" ")
x = 1
for i in list:
  x = x * int(i)
  if x > 10**18:
    print(-1)
    exit()
print(x)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

import sys
import math 

#Input Functions
#===============

input = sys.stdin.readline

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

#===============

def run_test() :
    n = inp()
    a = inlt()
    ans = 1
    zero = False
    invalid = False
    for i in a :
        ans *= i
        if i == 0 : zero = True
        if i > 1e18 : invalid = True
    if zero : ans = 0
    elif invalid : ans = -1
    print(ans)

def main() :
	run_test()

if __name__ == '__main__' :
	main()

Submission status: Wrong Answer

Solution code:
"""
    This template is made by Satwik_Tiwari.
    python programmers can use this template :)) .
"""

#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().strip() #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)


#===============================================================================================
# code here ;))

def solve():
    n = int(inp())
    a = lis()
    ans = 1
    for i in range(0,n):
        if(a[i] == 0 or ans>(10**18)):
            break
        ans *= a[i]
    if(ans>(10**18)):
        print(1)
    else:
        print(ans)

testcase(1)

Submission status: Wrong Answer

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

if(flag):
    print(-1)
else:
    print(prod)

Submission status: Wrong Answer

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

x=1

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

Submission status: Wrong Answer

Solution code:
INF = int(1e18)


def main():
    N, *A, = map(int, open(0).read().split())
    ans = 1
    for a in A:
        ans *= a
        if INF < ans:
            print(-1)
            break
    else:
        print(ans)
    return


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
sum = 1
for i in a:
  sum*=int(i)
  if sum>10**18:
    sum=-1
    break
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
sum = 1
for i in a:
  sum*=int(i)
  if sum>10**18:
    print(-1)
    exit()
print(sum)

Submission status: Wrong Answer

Solution code:
n = input()
a_array = input().split(" ")

seki = 1
end = False

if "0" in a_array:
    print(0)
else:
    for a in a_array:
        a = int(a)
        seki *= a

        if seki > 10**18:
            print(-1)
            end = True
            break

    if end == False:
        print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
sum = 1
for i in a:
  sum*=int(i)
  if sum>10**18:
    print(-1)
    break
print(sum)

Submission status: Wrong Answer

Solution code:
n = input()
a_array = input().split(" ")

seki = 1
end = False
for a in a_array:
    a = int(a)
    
    if a == 0:
        print(0)
        end=True
        break
    
    seki *= a
    
    if seki > 10**18:
        print(-1)
        end = True
        break

if end == False:
    print(a)

Submission status: Wrong Answer

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

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

if(ans > 10^18):
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = map(int,input().split())
    result = 1
    if 0 in A:
        print(0)
        return

    for i in A:
        result *= i
        if result > 1000000000000000000:
            print(-1)
            return
    print(result)

main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = map(int,input().split())
    result = 1
    if 0 in A:
        print(0)
        return

    for i in A:
        result *= i

    if result > 1000000000000000000:
        print(-1)
        return
    print(result)

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=1
l=list(map(int,input().split()))
for x in l:
  if x==0:
    print(-1)
    exit()
for x in l:
  ans=ans*x
  if(ans>1000000000000000000):
    break
if(ans>1000000000000000000):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

p = math.prod(map(int, input().split()))
print(p if p <= 1e18 else -1)

Submission status: Wrong Answer

Solution code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]



result = 0
if 0 in x2:
  None 
else:
  result + 1
  for xv in x2:
  
     result = xv * result
  
     if xv == 0:
        result = 0
        break
  
     if 10**18 < result : 
        result = -1
        break


print(result)

Submission status: Wrong Answer

Solution code:
import sys 
input = sys.stdin.readline
 
 
n = int(input())
 
a= list(map(int,input().split())) 
 
from operator import mul
from functools import reduce
 
ans = 1
for i in a:
    ans *= i 
    
    if ans > 10**18:
        print('-1')
        quit()

print(ans)

Submission status: Wrong Answer

Solution code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]
 
result = 1
for xv in x2:
   if xv == 0:
       result = 0
       break;

   result = xv * result
       
   if 10**18 < result : 
       result = -1
       break
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
t=1
for b in[*open(0)][1].split():
 t*=int(b)
 if t>1e18:t=-1;break
print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split(" "))
ans = 0
for i in a:
  ans += i
if ans > 1e18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
AA = int(np.prod(A))

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
AA = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
import sys
#import cython
 
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    n = int(read())
    a = list(map(int,read().split()))
    ans = 1
    flag = True
    for num in a:
      ans *= num
      if ans > 10**18:
        flag = False
        break
    print(ans if flag else -1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
num_list = list(map(int, input().split()))
result = 1

for number in num_list:
    result = result * number
  
def if_test(result):
    if 10 ** 18 < result:
        print(-1)
    else:
        print(result)
        
if_test(result)

Submission status: Wrong Answer

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

for number in li:
	result = result * number
    
if 10**18 <= result:
	print(result)
else:
  	print(-1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from decimal import Decimal
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

'''
N = ii()
A = li()
ans = 1
inf = Decimal('1000000000000000000')
for num in A:
    if ans <= inf / Decimal(str(num)):
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()
print(ans)
'''

N = ii()
A = li()
if 0 in A:
    print(0)
    exit()
ans = 1
for num in A:
    if ans <= 10**18 / num:
        ans *= num
    else:
        print(-1)
        exit()
 
print(ans)

Submission status: Wrong Answer

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

MAX = 10 ** 18
ret = 1

for x in xs:
  ret *= x
  
  if x >= MAX:
    print(-1)
    exit(0)
    
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from decimal import Decimal
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

'''
N = ii()
A = li()
ans = 1
inf = Decimal('1000000000000000000')
for num in A:
    if ans <= inf / Decimal(str(num)):
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()
print(ans)
'''

N = ii()
A = li()
if 0 in A:
    print(0)
    exit()
ans = 1
for num in A:
    if ans < 10**18 / num:
        ans *= num
    else:
        print(-1)
        exit()
 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from decimal import Decimal
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

'''
N = ii()
A = li()
ans = 1
inf = Decimal('1000000000000000000')
for num in A:
    if ans <= inf / Decimal(str(num)):
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()
print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans < 10**18 / num:
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()
 
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import collections

N = int(input())
A = list(map(int, input().split()))
res = 1
if 0 in A:
    print(0)
    sys.exit()
for i in range(N):
    res *= A[i]
    if res > 1e18:
        print(res)
        sys.exit()
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import collections

N = int(input())
A = list(map(int, input().split()))
res = 1
if 0 in A:
    print(0)
    sys.exit()
for i in range(N):
    res *= A[i]
    if res > 1e18:
        print(res)
        print(-1)
        sys.exit()

print(res)

Submission status: Wrong Answer

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

print(-1)

Submission status: Wrong Answer

Solution code:
from typing import Any, Union


def find_factors(number):
    """
    Print prime factors.
    :param number: <int> number
    :return: <None>
    """
    global count
    count = count + 1
    is_prime = True
    for i in range(2, int(number ** 0.5 + 2),):

        if number %(i)== 0:

            is_prime = False
            
            find_factors(int(number / (i*i)))

            break


    if (is_prime and number!=1):

        print(str(number), end=" ")


    if (number==1 or number==0) :
        count=count-1
    return





try:
    number = int(input())
    count = 0
    if number <= 0:
        raise Exception
    find_factors(number)
    print(count)
except Exception as e:
    exit()

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

n   = int(input())
a_s = map(int, input().split())

result = reduce(mul, a_s)

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans <= 10**18 / num - 10**(-9):
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans <= 10**18 / num - 0.1:
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans < 10**18 / num:
        #print(ans, 10**18 / num)
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans <= 10**18 / num:
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
l = list(map(int, input().split()))
mul = 1
if 0 in l:
    print(0)
else:
    for num in l:
        mul *= num
        if mul > 1e18:
            print(-1)
    print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  data = list(map(int, input().split()))
  if 0 in data:
    print(0)
    return
  
  c = 1
  for d in data:
    c *= d
  
  if c >= 10 ** 18:
    print(-1)
  else:
    print(c)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  data = list(map(int, input().split()))
  if 0 in data:
    print(0)
    return
  
  c = 1
  for d in data:
    c *= d
    if c >= 10 ** 18:
      print(-1)
      return
  
  print(c)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
t=int(input())
c=list(map(int,input().split()))
if 0 in c:
    print(0)
m=1
for i in c:
    m*=i
    if(m>1000000000000000000):
        print(-1)
print(m)

Submission status: Wrong Answer

Solution code:
input()
mul = 1
l = list(map(int, input().split()))
for num in l:
  mul *= num
  if mul > 1e18:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
sA=input().split(" ")
A=np.array(sA,dtype=np.int64)

flag=False

zero=False
th=pow(10,18)
for i in range(N):
    if(A[i]==0):
        zero=True
        break
    elif(A[i]>th):
        flag=True
        break

S=1
for i in range(N):
    S*=A[i]
    if(S>th):
        flag=True
        break

if(zero):
    print(0)
else:
    if(flag):
        print(-1)
    else:
        print(S)

Submission status: Wrong Answer

Solution code:
import math
n=input()
a=list(map(int,input().split()))
x=pow(10,18)
s=int(1)
c=True
for i in a:
	s*=i
	if(s>x):
		print('-1')
		c=False
		break
if c:
	print(s)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
t=int(input())
c=list(map(int,input(). split ()))
if 0 in c:
    print(0)
m=1
for i in c:
    m*=i
    if(m>1000000000000000000):
        print(-1)
print(m)

Submission status: Wrong Answer

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

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

for i in range(N):
    if A[i] <= (10**18 / ans):#普通だったらオーバーフローしないようにやる
        ans *= A[i]
    else:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

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

for i in range(N):
    if A[i] < (10**18 / ans):#普通だったらオーバーフローしないようにやる
        ans *= A[i]
    else:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

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

for i in range(N):
    if A[i] < (10**18 / ans):
        ans *= A[i]
        print(ans)
    else:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

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

for i in range(N):
    if A[i] < (10**18 / ans):#普通だったらオーバーフローしないようにやる
        ans *= A[i]
        print(ans)
    else:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

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

for i in range(N):
    if A[i] < (10**18 / ans):#普通だったらオーバーフローしないようにやる
        ans *= A[i]
        print(ans)
    else:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    k = input()
    n = [int(x) for x in input().split()]
    ans = 1
    flag = False
    print(n)
    for i in n:
        # print(ans)
        ans *= i

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

main()

Submission status: Wrong Answer

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

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

for i in range(N):
    # if ans > pow(10,18):#pythonはオーバーフローしないからこれでも行ける
    if A[i] > 10**18/ans:#普通だったらオーバーフローしないようにやる
        ans = ans*A[i]
        # ans *= A[i]#こう書け
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

if 0 in A:
    print(0)

ans = 1
for i in A:
    ans *= i
    if ans > 1000000000000000000:
        print(-1)
        quit()

print(ans)