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:
n = int(input())
a = list(map(int, input().split()))
p = 1
large = 0
for x in a:
  p *= x
  if p > 10**18:
    large = 1
    break
if large:
  print(-1)
else:
  print(p)

Submission status: Wrong Answer

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

res = 1
for a in a_list:
    res *= a
    if res > (10 ** 18):
        res = -1
        break
print(res)

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
     break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = (int(x) for x in input().split())
number =1

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

print(number)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
AList = input().split()

result = 1

for element in AList:
    result = result * int(element)

    if result > 1e+18:
        print(-1)
        sys.exit()

print(result)

Submission status: Wrong Answer

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

  main()

Submission status: Wrong Answer

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

n = int(input())

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

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            product = -1
            exit()
            

print(product)

Submission status: Wrong Answer

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

res = 1
for a in a_list:
    res *= a
if res // (10 ** 18) == 1:
    res = -1
print(res)

Submission status: Wrong Answer

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

ans =1
for I in b:
  ans = ans*I
  if ans > 10**18:
    print('-1')
    break
print(ans)

Submission status: Wrong Answer

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

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

for i in A:
    ans *= i
    if ans < lim:
        break

if ans < lim:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
AList = input().split()

result = 1

for element in AList:
    result = result * int(element)

    if result > 1e+18:
        print(-1)

print(result)

Submission status: Wrong Answer

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

ans =1
for I in b:
  ans = ans*I
  if ans > 10**18:
    print(-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 (10**18+1)//ans <= a[i]:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

A = sorted(A, reverse=True)

M = 1

for i in range(N):
  if M <= 10**18 :
    M = M * A[i]

  else:
    break

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

else:
  print("-1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input()) 

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

ans = 1;
for i in range(n):
  if a[i] == 0:
    print('0')
    sys.exit()
    
  ans *= a[i]
  if (ans > 1000000000000000000):
    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:
    ans = 0
else:
    a.sort(reverse=True)
    for i in a:
        if ans>(10**18):
            ans = -1;break
        ans = ans*i
print(ans)

Submission status: Wrong Answer

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

if alist[0]==0:
  print(0)
  sys.exit(0)

answer=1
for a in alist:
  answer*=a
  if answer>1<<18:
    print(-1)
    break
else:
  print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input()) 

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
#B
import numpy as np
import sys
n = int(input())
A = np.array(list(map(int,input().split())))
A.sort()
ans = 1
flag = True
for i in A:
    if flag:
        ans *= i
        if ans > 10**18:
            ans = -1
            flag = False
    else:
        if i == 0:
            ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
result=1
for i in range(n):
	result *= a[i]
	if result > 1000000000000000000 and a[i] != 0:
		print(-1)
		exit()
if result > 1000000000000000000:
	print(-1)
else:
	print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x)for x in input().split()]
T = 1
for x in A:
    T *= x
    if T > 10 ** 18:
        print(-1)
        exit()
print(T)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
AList = np.array(input().split(), dtype=int)
result = AList.prod()

if result > 1e+18:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
result=1
for i in range(n):
	result = result * a[i]
	if result > 100000000000000000 and a[i] != 0:
		print(-1)
		exit()
if result > 100000000000000000:
	print(-1)
else:
	print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#B
import numpy as np
import sys
n = int(input())
A = np.array(list(map(int,input().split())))
ans = 1
flag = True
for i in A:
    if flag:
        ans *= i
        if ans > 10**18:
            ans = -1
            flag = False
    else:
        if i == 0:
            ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for x in a:
  ans *= x
if x > pow(10, 18):
  print(-1)
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:
     ans = -1
     break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
AList = np.array(input().split(), dtype=np.int64)
result = AList.prod()

if result > 1e+18:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

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

flag = 0
if data.count(0) > 0:
	print(0)
else:
  a = data[0]
  for i in range(1,n):
    a = a*data[i]
    if a > 10**18:
      flag = 1
      break
      
    if flag == 1:
      print('-1')
    else:
      print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = (int(x) for x in input().split())
number =1

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

print(number)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

N = int(input())
A = np.array([int(a) for a in input().split()])

if np.prod(A)>10**18:
    print(-1)
    sys.exit()
else:
#    print(type(int(np.prod(A))))
    print(int(np.prod(A)))

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = 1
flag = True
a = list(map(int, input().split()))

a.sort()

print(a)

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

for i in a:
    ans *= i
    if ans > 10**18: 
        flag = False


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

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N = int(input())
AList = np.array(input().split(" "), dtype=np.int64)
result = AList.prod()
 
if result > 1e+18:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

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

x = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        x *= a[i]
    
    if x /10**8 > 10**10:
        print(-1)
    else:
        print(x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
LIMIT = 10 ** 18
n=int(input())
#a=(int,read.split())
a=[int(i) for i in input().split()]
#if 0 in a:
#	print(0)
#	exit()

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

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
b = 1
for a in A:
  if b > 10**18:
    break
  b *= a
print(-1 if b > 10**18 else b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

new = 1
for i in range(n):
	new *= a[i]
	if new > pow(10,18):
		new = -1
		break
print(new)

Submission status: Wrong Answer

Solution code:
#B
import numpy as np
import sys
n = int(input())
A = np.array(list(map(int,input().split())))
ans = 1
for i in A:
    ans *= i
if ans > 10**18:
    ans = -1
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import functools
import operator
def II(): return int(input())
def LII(): return double(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    #A = [0]*N
    ans = 1
    A= LI()
    
    if A.count(0)>0:
        print(0)
    else:
        for i in range(N):
            ans = ans*int(A[i])
            if ans/1e+18>1:
                print(-1)
                break


        if ans/1e+18<=1:
            print(ans)
    


    


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

product = 1

for i in range(n):
    if  num[i-1]== 0:
        product = 0
        break
    if product != -1:
        product = product * num[i-1]
        if product > 10**18:
            product = -1
            break

print(product)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = (int(x) for x in input().split())
number =1

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

print(number)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
s=1
for c in range(n):
    s=s*a[c]
    if s>10**18:
        s=-1
        break
print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N = int(input())
AList = np.array(input().split(" "), dtype=np.int64)
result = AList.prod()
 
if result > 10 ** 18:
    print("-1")
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
import math
b = [math.log10(i) for i in a if i!=0]    
if sum(b)>18:
    print(-1)
else:
    z = 1
    for i in a:
        z*=i
    if z>10**18:
        print(-1)
    else:
        print(z)

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
s=0
if a.count(0) == 0:
  s=1
  for i in range(n):
    l=a.pop()
    s=s*l
  
    if len(str(s)) == 19 and i == n-1:
      break
      
  
    if len(str(s)) >= 19:
      s=-1
      break

    
print(s)

Submission status: Wrong Answer

Solution code:
import numpy

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

val = numpy.prod(A, dtype='i8')

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] == 0:
        res = 0
    elif A[i] > 0:
        res *= A[i];
    if abs(res) > 1e+18:
        res = -1

if res > 1e+18: print("-1")
else          : print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().split()
    ans = 1
    if N > 59:
        print(-1)
    elif "0" in A:
        print(0)
    else:
        for i in A:
            ans = int(i) * ans
            if ans > 1e+18:
                print(-1)
                return
        else:
            print(ans)
        return
resolve()

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
s=0
if a.count(0) == 0:
  s=1
  for i in range(n):
    l=a.pop()
    s=s*l
  
    if len(str(s)) == 19 and i == n-1:
      lst=list(str(s))
      
  
    if len(str(s)) > 19:
      s=-1
      break

    
print(s)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
import sys
N=Decimal(input())
L=list(map(Decimal,input().split()))
M=Decimal(100000000000000000000000000000000000000000000000000000000000000000000)
M=1
for i in L:
    if M>1000000000000000000:
        print(-1)
        break  
    else:
        M=M*i
    print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
s=1
if a.count(0) == 0:
  for i in range(n):
    l=a.pop()
    s=s*l
  
    if len(str(s)) == 19 and i == n-1:
      lst=list(str(s))
      
  
    if len(str(s)) > 19:
      s=-1
      break

    
print(s)

Submission status: Wrong Answer

Solution code:
import numpy

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

val = numpy.prod(A)

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

Submission status: Wrong Answer

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

for num in A:
  ans = ans * num
  if num != 0:
    if ans / num != tmp:
      is_overflow = True
      break
  elif num == 0:
    is_overflow = False
    ans = 0
    break

  tmp = ans

if (ans > 1e18 or ans < 0 or is_overflow): ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().split()
    ans = 1
    if N > 59:
        print(-1)
    elif "0" in A:
        print(0)
    else:
        for i in A:
            ans = int(i) * ans
            if ans > 10**18:
                print(-1)
                return
        else:
            print(ans)
        return
resolve()

Submission status: Wrong Answer

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

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 > 1000000000000000000:
        print(-1)
        exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if 0 in a :
    ans  = 0
    print(ans)
else :
    ans = 1
    for i in range(n):
        ans *= 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

for i in A:
    ans *= i

    if ans > (10**18):
        print(-1)
        exit(0)
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 > 1000000000000000000:
        print(-1)
print(ans)

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int, input().split()))

from operator import mul
from functools import reduce

n = int(input())
a = readInt()
ans = 1
judge = True
a.sort(reverse=True)
if 0 in a:
    print(0)
    judge = False
else:
    for i in a:
        ans *= i
        if ans > 10*18:
            print(-1)
            judge = False
            break
        
if judge:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n = int(input())

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

ans = np.prod(a)

if ans > 10**18 or ans < 0:
    print(-1)
    sys.exit()

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
A_list.sort()
#print(A_list)
if A_list[0]==0:
    answer = 0
else:      
    answer = 1
    for a in A_list:
        answer *= a
        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()))
a=sorted(a)[::-1]
ans=a[0]
for i in a[1:]:
    ans*=i
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
At = 1
X = 0
for p in range(N):
    X = X + len(str(A[p])) -1

if X < 19 :
    for j in range(N) :
        At = At * A[j]
    print(At if At <= 10**18 else "-1")

else :
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy

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

val = numpy.prod(A)

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

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int, input().split()))

from operator import mul
from functools import reduce

n = int(input())
a = readInt()
ans = 1
judge = True
a.sort(reverse=True)
if 0 in a:
    print(0)
    judge = False
for i in a:
    ans *= i
    if ans > 10*18:
        print(-1)
        judge = False
        break
    
if judge:
    print(ans)

Submission status: Wrong Answer

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

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:
        if 0 in a:
            print(0)
        else:
            print(-1)
    else:
        print(x)

Submission status: Wrong Answer

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


def solve(N: int, A: "List[int]"):
    if 0 in A:
        print(0)
    prod = 1
    for a in A:
        prod *= a
        if prod > int(1e18):
            print(-1)
            return
    print(prod)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=input()
ls=[int(s) for s in input().split()]
ans=1
flag=1
for e in ls:
  ans*=e
  if ans>10**18:
    flag=0
    break
if flag==1:
  print(ans)
else:
  print(-1)

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):
    ans = ans * a[i] // 1
    if ans > 10**18:
        flag = 1
        break



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

Submission status: Wrong Answer

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

for i in A:
    ans *= i

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

Submission status: Wrong Answer

Solution code:
import numpy as np
input()
x = np.array(list(map(int,input().split())))
p = np.prod(x)
print(p if p<=1e+17 else -1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
 
n=int(input())
i = list(map(int, input().split()))
ans = np.prod(i)
 
if ans>1e18:
  ans=-1
  
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,*a=map(int,open(0).read().split())
s=1
a=np.array(a)
if any(a==0):
  print(0)
  exit()
for i in list(a):
  if i>=10**18/s:
    print(-1)
    exit()
  s=s*i
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
input()
x = np.array(list(map(int,input().split())))
p = np.prod(x)
print(p if p<=10e+17 else -1)

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int, input().split()))

from operator import mul
from functools import reduce

n = int(input())
a = readInt()
ans = 1
judge = True
a.sort(reverse=True)
for i in a:
    ans *= i
    if ans > 10*18:
        print(-1)
        judge = False
        break
    elif ans == 0:
        print(0)
        judge = False
        break
if judge:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    break
    if A[i] == 0:
        res = 0
    elif A[i] > 0:
        res *= A[i];
    if res > 1e+18:
        res = -1

if res > 1e+18: print("-1")
else          : print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(input().split())

answer = 1
i = 0
while len(str(answer-1))<=18 and i<N: 
    answer *= int(A_list[i])
    i+=1

if i==N-1:
    print(answer)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for i in range(num):
    if nums[i] == 0:
        ans = 0
if ans != 0:
    for i in range(num):
        ans *= nums[i]
    if len(str(ans)) > 18:
        ans = -1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 j in range(0, kaisu):
    if(val/10**18 < 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
import sys
N=Decimal(input())
L=list(map(Decimal,input().split()))
M=Decimal(100000000000000000000000000000000000000000000000000000000000000000000)
M=1
for i in L:
    if M>1000000000000000000:
        print("-1")
        sys.exit()    
    else:
        M=M*i
print(M)

Submission status: Wrong Answer

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

s = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    lim = pow(10,18)
    ans = 1
    for a in la:
        ans *= a
        if ans > lim:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for i in range(num):
    if nums[i] == 0:
        ans = 0
if ans != 0:
    for j in range(num):
        ans *= nums[j]
        if len(str(ans)) > 18:
            ans = -1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# coding: utf-8
import sys

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

for j in range(0, kaisu):
    if(num[i]/10**18 < 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

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

s = np.prod(a)

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