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:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
        if a[i] == 0:
          print(0)
          break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10^18:
        print(-1)
        exit()
print(x if x<=10**18 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
  if mt.log10(ans) - 10**18 > 0:
    print(ans)
  else:
    print(-1)
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = input()

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

res = np.prod(a)

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

else:
    print(res)

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:
import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
a = np.array(a_list,int)
total = a.prod()
if total > 10**18:
    print(-1)
else:
    print(int(total))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
import math 
k = input()
x = [int(x) for x in input().split()] 
yes = math.prod(x) 
if yes > 10^18:
    print (-1)
else:
    print(yes)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1

if a > 10^18:
  a = -1
 
print(a)

Submission status: Wrong Answer

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

for i in num_list:
    if i==0:
        print(0)
        exit()
    i=str(i)
    sum=str(sum)
    
    if len(i)+len(sum)>21:
        print(-1)
        exit()
    i=int(i)
    sum=int(sum)
    sum=sum*i
    if sum>10**18:
        print(-1)
        exit()
print(sum)

Submission status: Wrong Answer

Solution code:
overf = 1000000000000000000
n = int(input())
res = 1
arr = list(map(int, input().split()))
for i in range(n):
    a = arr[i]
    if(a==0):
        res=0
        break
    res = res*a
    if(res>overf):
        res=-1
        break
print(res)

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 :
    ans = -1

print(ans)

Submission status: Wrong Answer

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

for i in range(N):
    num = A[i]
    ans *= num
    if ans <= 0:
        break
    elif ans > 10**18:
        ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='int64')
    ans = int(np.prod(A))
    if ans > 10**18:
        print('-1')
        exit(0)
    print(ans)
main()

Submission status: Wrong Answer

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

import numpy as np
mul = np.prod(A)

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

else:
    print(mul)

Submission status: Wrong Answer

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

import numpy as np
arrayA = np.array(A)
p = np.prod(arrayA)

if 0 in A:
  print(0)
else:
  arrayA = np.array(A)
  p = np.prod(arrayA)
  if p > 10**18:
    print(-1)
  else:
    print(p)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

total = 1
for n in A:
    if total <= 10 ** 18:
        total *= n
        print(total)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int,input().split())))
    sumlogA = sum(np.log10(A))
    ans = 1
    if 0 in A:
        print(0)
    elif sumlogA < 18.1:
        for i in range(N):
            ans = int(A[i]) * ans
        if ans > 10**18:
            print(-1)
        else:
            print(ans)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if f: print(ans)
else: print(-1)

Submission status: Wrong Answer

Solution code:
import math
import sys
C = int(input())
Lista = list(map(int, input().split()))
ans = 0

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

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

Submission status: Wrong Answer

Solution code:
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split()))

result = 1
for x in range(N):
  result *= i[x]
  if(result>pow(10,18)):
    result = -1
    break
    
print(result)

Submission status: Wrong Answer

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

list.sort(A, reverse=True)
mx = 10 ** 18
mul = 1
for a in A:
    mul *= a
    if mul == 0:
        break
    elif mul > mx:
        mul = -1
        break

print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 1e18:
            ans = "-1"
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(f)

Submission status: Wrong Answer

Solution code:
import numpy
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = numpy.prod(lst)
    if output <= 10**8 :
        print(output)
    else :
        print(-1)
else :
    exit()

Submission status: Wrong Answer

Solution code:
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
ans = 1
INF = 1000000000000000000
for i in a:
    ans *= i
    if (ans > INF):
        print("-1")
        sys.exit()
    elif (ans == 0):
        print("-1")
        sys.exit()


print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    if math.log10(a[i]) > 18 or math.log10(ans) + math.log10(a[i]) > 18:
        flag = 1
        break
    else:
        ans = ans * a[i]

 
if flag == 1:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans= 1

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

Submission status: Wrong Answer

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

answer = 1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
z=list(map(int,input().split()))
mul=1
for i in z:
    mul=mul*i
print(mul)

Submission status: Wrong Answer

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

LIMIT = 10 ** 18

res = 1
for a in A:
    res = res * a
    if res > LIMIT:
        break

# res = math.exp(sum([math.log(a) for a in A]))

# X = np.array(A)
# res = X.prod()
#
# print(X)

# for a in A:
#     math.log(a)
#
#     res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
val = 1
for i in range(0, kaisu):
    if(num[i] == 0):
        print('0')
        sys.exit()

for i in range(0, kaisu):
    if(val > 1000000000000000000 and num[i] != 0):
        print('-1')
        sys.exit()
    val = val * num[i]

print(val)

Submission status: Wrong Answer

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

for i in range(N):
  ans = ans * A[i]
  if ans > 10 ** 18:
    break

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

Submission status: Wrong Answer

Solution code:
a=int(input())
b=map(int,input().split())
b=[int(i) for i in b]
c=1
for i in b:
    c=c*i
if(c<10**18):
    print(c)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
lim = 10**18
ans,exc = 1,False
a = map(int,input().split())
if 0 in a:
  print(0)
else:
  for x in a:
    ans *= int(x)
    if ans > lim:
      exc = True
      print("-1")
      break
  if not exc:
    print(ans)

Submission status: Wrong Answer

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

ans = 1
for i in l:
    ans *= i
    if ans > 10**18:
        ans = -1
        break


print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
mul = 1
for n in map(int, input().split()):
    mul *= n
    if mul > 10 ** 18:
        print(-1)
        exit()
print(mul)

Submission status: Wrong Answer

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


z = 1
for i in range(0, n):
  z = z * a[i]
  if z > 1000000000000000000:
    print("-1")
    break


if z <= 1000000000000000000:
  print(z)

Submission status: Wrong Answer

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

mul = 1
if 0 in set(a): print(0)
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul > 1e18:
            mul = -1
            break
print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans >= 1e18:
        ans = '-1'
        break
for a in A:
    if a == 0:
        ans = 0
if ans == '-1':
  print(ans)
else:
  print(int(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break

Submission status: Wrong Answer

Solution code:
import functools
import operator

n = int(input())
a = list((map(int,input().split())))
print(a)
def __main__():
    prod = functools.partial(functools.reduce, operator.mul)
    ans = prod(a)
    if(ans>10**18):
        print(-1)
    else:
        print(ans)
    return

if(__name__=="__main__"):
    __main__()

Submission status: Wrong Answer

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

multi = 1
for i in range(n):
    multi = multi * a[i]
    if multi > 100000000000000000:
        print(-1)
        break
if multi <= 100000000000000000:
    print(multi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(n):
  ans *= int(a[i])
  if ans > 10**18:
    print("-1")
    break
    
if ans < 10**18:
  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 a:
    ans *= i
    if ans>10**8:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

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

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

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if 0 in a:
    print(0)
    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:
a = int(input())
b = list(map(int,input().split()))

n = 1
m = 1

aa = a/2

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

for i in range(int(aa)):
  n = n * b[i]
  
for i in range(int(aa),a):
    m *= b[i]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

for i in A:
    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
ans=1
m1=list(map(int,input().split()))
#for i in range(n):
#  ans=ans*m[i]
m2=np.array(m1)

ans=np.prod(m2)

if ans<=pow(10,18):
  print(ans)
else:
  print(-1)
  
#print(pow(10,18))
#print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = map(int, input().split())
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:
N = int(input())
numList = list(map(int, input().split()))
product = 1
isZero = False
toPrint = True
for j in numList:
    if j == 0:
        isZero = True
        break
if not isZero:
    for i in numList:
        product = product * i
        if product > 10**18:
            toPrint = False
            break
if toPrint and not isZero:
    print(product)
if isZero:
    print(-1)
if not toPrint:
    print(-1)

Submission status: Wrong Answer

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

if(N%2==0):
    for i in range(int(N/2)):
        ans *= (A[i]*A[N-1-i])
        if(ans>1000000000000000000):
            break
else:
    for i in range(int(N/2)):
        ans *= A[i]*A[N-1-i]
        if(ans>1000000000000000000):
            break
    ans*=A[int((N-1)/2)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

ans = str(reduce(mul, L))

if len(ans) <= 19:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy

n = int(input())

num = [0] * n
num = list(map(int, input().split()))

if 0 in num:
    print(0)
else:
    mult = numpy.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(mult)

Submission status: Wrong Answer

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

for i in range(n):
  x*=a[i]
  if x<=1000000000000000000:
    continue
  else:
    print("-1")
    exit()
  
print(x)

Submission status: Wrong Answer

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


import numpy as np
B = np.array(li)
if np.prod(B) > 10**18:
    print(-1)
else:
    print(np.prod(B))

Submission status: Wrong Answer

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

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:
import numpy as np
n = int(input())
a = list(map(int, input().strip().split()))
x = np.prod(a)
if x > 10**18:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

n =int(input())
l = list(map(int,input().split()))
   
arr = np.asarray(l)
p = np.prod(l)

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

print(p)

Submission status: Wrong Answer

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

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

print (ans)

Submission status: Wrong Answer

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

if result <= 1000000000000000001 :
    print(result)
else:
	print("-1")

Submission status: Wrong Answer

Solution code:

def main():
	n = int(input())
	a = map(int, input().split(" "))
	for ai in a:
		if ai== 0:
			print("0")
			return
	ans = 1
	for ai in a:
		ans *= ai
		if ans > 1e18:
			print("-1")
			return
	print(ans)

if __name__ == '__main__':
	main()

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

Submission status: Wrong Answer

Solution code:
answer = 1
lens = int(input())
arrs = [int(x) for x in input().split()]
for x in arrs:
    answer *= x
    if answer > int(10 ** 18):
        answer = -1
        break
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
num = 1
flag = 0
c=list(map(int, input().split()))
for i in c:
    if i == 0:
        flag = 1
        print("-1")
if flag ==0:
    for i in c:
        num *= i
    if num > 1000000000000000000:
        print("-1")
    else:
        print(num)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 1
lim = 18
now = 0
for a in A:
    ans *= a
    now += len(str(a))-1
    if now >= 18:
        print(-1)
        exit()
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)
print(ans if ans <= 10**18 else -1)

Submission status: Wrong Answer

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

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

if(0 in list):
  print('0')
  exit()

for i in range(n):
  result = result * list[i]
  if(result >= 1000000000000000000):
    print('-1')
    exit()

print(result)

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:
from operator import mul
from functools import reduce
N=int(input())
li = list(map(int,input().split()))	
if reduce(mul, li)>=10**18:
  print("-1")
else:
  print(reduce(mul, li))

Submission status: Wrong Answer

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

if ans > 10000000000000000000:
  ans=-1
  
print(ans)

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:
        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()))
p = np.prod(a)
if p > 10**18:
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

Solution code:
N = int(input())
List = list(map(int, input().split()))
a=1
if  0 in List:
    print(0)
else:
    for i in range(N):

        a=a*List[i]
        if a>10**18:
            print('-1')
            break   
    print(a)
    if not a>10**18:
        print(a)

Submission status: Wrong Answer

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

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)
        # sys.stderr.write('{}\n'.format(logsum))


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

    for a in As:
        prod *= a

    if prod >= 10 ** 18:
        print('-1')
        return
    print(prod)

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

    return 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:


import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 1e18:
            ans = -1
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
List=list(map(int,input().split()))
ans=1
for i in range(len(List)):
    if 0 in List:
        print(0)
        sys.exit()
    else:
        if ans<=10**18:
            ans*=List[i]
        else:
            print(-1)
            sys.exit()
print(ans)

Submission status: Wrong Answer

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

maxval = 10 ** 18
ans = 1

for i in a:
    if i <= maxval:
        ans = -1
        break
    
    if ans <= maxval:
        ans *= i
    else:
        ans = -1
        break

print(ans)

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

Submission status: Wrong Answer

Solution code:
_ = input()
inp = map(int, input().split())

of = False
re = 1

for a in inp:
    re *= a
    if re > (10**18):
        of = True
        re %= (10**18)

if of and re > 0:
    re = -1

print(re)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

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

ans = Decimal('1')
for i in a:
    ans = Decimal(str(ans * i))
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.longlong)
# print(N, A)
if 0 in A:
    result = 0
else:
    result = np.prod(A)
M = 10 ** 18
if result > M:
    result = -1
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
elif N>6:
    print(-1)
else:
    mul=1
    for a in A:
        mul*=a
    print(mul if mul<=10**18 else -1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = 1
zero = 0
over = 0
for i in range(len(a)) :
	if a[i] == 0:
		zero = 1
for i in range(len(a)) :
	if over : break
	ans *= a[i]
	if ans > 1e18 :
		over = 1
if over : print(-1)
elif zero : print(0)
else : print(ans)

Submission status: Wrong Answer

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

AA = 1
for i in range(len(A)):
    AA = AA * A[i]
    if AA > 1000000000000000000:
        print(-1)
        break

print(AA)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))
q = 1
f = 0
for i in a:
    q *= i
    if q > 10**18:
        f = 1
        break
if f == 1:
    print(-1)
else:
    print(q)

Submission status: Wrong Answer

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

for i in Alist:
    p *= i
    if p >= 10**18:
        flag = False
        break
    else:
        continue
    
if flag:
    print(p)
else:
    print("-1")

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

Submission status: Wrong Answer

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

for i in range(N):
    num = A[i]
    ans *= num
    if ans <= 0:
        break
    elif ans >= 10**18:
        ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
import functools
import operator

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

count = int(input())
list = list(map(int, input().split()))
sum = prod(list)

if sum >= 1000000000000000000:
    sum = -1

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

list.sort(A, reverse=True)
mx = 10 ** 18
mul = 1
for a in A:
    mul *= a
    if mul == 0:
        break
    elif mul > mx:
        mul = -1

print(mul)

Submission status: Wrong Answer

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

result = 1

for num in num_list:
    result = result * num

if len(str(result)) > 17:
    if result != 1000000000000000000:
        result = -1

print(result)

Submission status: Wrong Answer

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

import numpy as np
arrayA = np.array(A)
p = np.prod(arrayA)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
t = A[0]
for i in range(1, N):
    if t > 1e18:
        break
    t *=  A[i]
if t > 1e18:
    print(-1)
else:
    print(t)