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: Accepted

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

ans=1
if 0 in X:
    print(0)
else:
    X.sort(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if 0 in a_list:
  ans = 0
else:
  for i in a_list:
    ans = ans * i
    if ans > 10 ** 18:
      ans = -1
      break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
A.sort(reverse=True)
t = A.pop()
if t == 0:
    print(0)
    exit(0)

A.append(t)

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

Submission status: Accepted

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

#print(a)

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 1
flag = True
for _ in a:
    c *= _
    if c > 10**18:
        flag = False
        c = 1
    if c == 0:
        print(0)
        quit()
if flag:
    print(c)
else:
    print(-1)

Submission status: Accepted

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

if 0 in A:
    print(0)
else:
    for a in A:
        pro *= a
        if pro > 1000000000000000000:
            print(-1)
            break
    else:
        print(pro)

Submission status: Accepted

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

if A.count(0):
    print(0)
    import sys
    sys.exit()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
m = 1
threshold = 1e18
for i in a:
    m *= i
    if m > threshold:
        m = -1  
        break
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
numbers = [int(x) for x in input().split()]
 
if any ([x == 0 for x in numbers]):
    t = 0
else:
    t = 1
    for i in numbers:
        t *= i
        if t > 10 ** 18:
            t = -1
            break
print(t)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
th = 10 ** 18
n = int(input())
a = map(int, input().split())

ans = 1
for ai in a:
  ans *= ai
  if ans > th:
    if 0 in a:
      print(0)
    else:
      print(-1)
    exit()
print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())
l = [int(x) for x in input().split()]

ans = 1

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

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Submission status: Accepted

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

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

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

print(prod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
x = list(map(int,input().split()))
x.sort()
ans = 1
limit = int(1e18)
flag = 1
if x[-1] == 0:
    print(0)
else:
    for i in range(n):
        ans *= x[i]
        if ans > limit:
            flag = 0
            break
    if flag ==1:
        print(ans)
    else:
        print(-1)

Submission status: Accepted

Solution code:
n = int(input())
lst = [int(x) for x in input().split()]
if lst.count(0) > 0:
  print("0")
else:
  product = 1
  for i in range(n):
    product *= lst[i]
    if product > 1000000000000000000:
      product = -1
      break
  print(str(product))

Submission status: Accepted

Solution code:
n = int(input())
cnt = 1
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    for i in l:
        cnt *= i
        if cnt > 10 ** 18:
            print(-1)
            exit()
        else:
            pass
    print(cnt)

Submission status: Accepted

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

while data[-1] == 0:
  data.insert(0,0)
  data.pop(-1)
 
ans = 1

for d in data:
  ans = ans * int(d)
  if ans > 10**18 or ans == 0:
    break
 
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = 1

if 0 in nums:
  print(0)
  exit()
  
for i in range(n):
  res = res * nums[i]
  if res <= 10**18 :
    continue
  else:
    res = -1
    break
print(res)

Submission status: Accepted

Solution code:
import sys
N = int(input())
num_list = [int(i) for i in input().split()]
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    
    Array=list(map(int, input().split(' ')[:N]))
    if 0 in Array:
        print(0)
        return
    mul=1
    for i in Array:
        mul*=i
        if mul > 1000000000000000000:
            print(-1)
            return
    
    print(mul)
main()

Submission status: Accepted

Solution code:
# B Multiplication 2

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

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(0)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

if 0 in a:
  print(0)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    if 0 in a:
        print(0)
        return

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

    print(res)

main()

Submission status: Accepted

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: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

  for a in A:
    if a == 0:
      print(0)
      return

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

  print(prod) 

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 1
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    for i in l:
        cnt *= i
        if cnt > 10 ** 18:
            print(-1)
            exit()
        else:
            pass
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = sorted(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: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

    if ary[0] == 0:
        print(0)
        return

    prod = 1
    for i in reversed(range(n)):
        prod *= ary[i]
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

    from math import log2
    lt = log2(10**18)

    if ary[0] == 0:
        print(0)
        return
      
    if any(log2(ary[i]) > lt / (n-i) for i in range(n)):
        print('-1')

    else:
        prod = 1
        for i in range(n):
            prod *= ary[i]
        if prod > 10**18:
            print(-1)
        else:
            print(prod)

main()

Submission status: Accepted

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
s=1
d=1
for i in l:
    s=s*i
    if(s>10**18):
        print(-1)
        d=0
        break
if(d==1):
    print(s)

Submission status: Accepted

Solution code:
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1
def powerMod(x,y,p):
    res=1
    x%=p
    while y>0:
        if y&1:
            res=(res*x)%p
        y=y>>1
        x=(x*x)%p
    return res
def gcd(x,y):
    while y:
        x,y=y,x%y
    return x
def isPrime(n):
    if(n<=1): return False
    if(n<=3): return True
    if(n%2==0 or n%3==0): return False
    i=5
    while(i*i<=n) : 
        if(n%i==0 or n%(i+2)==0) : 
            return False
        i=i+6
    return True
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def main():
    n=int(input())
    prod = 1
    arr=list(map(int,input().split()))
    if(0 in arr):
        print(0)
        return
    for i in arr:
        prod = prod*i
        if(prod>1e18):
            print(-1)
            return
    print(prod)

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 1
    A = list(map(int,input().split()))
    A.sort()
    for a in A:
        ans *= a
        if 1e18 < ans:
            print(-1)
            return 
    print(ans)

if  __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 1
lim = int(1e18)

if 0 in arr:
    print(0)

else:
    for x in arr:
        ans *= x
        if ans > lim:
            ans = -1
            break 

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

product = 1

for num in nums:
    product *= num

    if product > 1e18:
        product = -1
        break

if 0 in nums:
    product = 0

print(product)

Submission status: Accepted

Solution code:
n=int(input())
v=pow(10,18)
inp = list(map(int,input().split()))
prod=1
from collections import Counter
c=Counter(inp)
if c[0]>=1:
  print (0)
else:
  flag=1
  for item in inp:
    prod*=item
    if prod>v:
      flag=0
      print (-1)
      break
  if flag==1:
    print (prod)

Submission status: Accepted

Solution code:
x = input()
y = input().split()
ord = sorted(y)
t = 1
for z in ord:
    t *= int(z)
    if (int(z) == 0):
        break
    if t > 1000000000000000000:
        print(-1)
        exit(0)
print(t)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
k = 1
flag = True
for i in a:
  k *= i  
  if k > 10 ** 18:
    flag = False
    break

if 0 in a:
  print(0)
elif flag:
  print(k)
else:
  print(-1)

Submission status: Accepted

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

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())
an = [int(num) for num in input().split()]

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

answer = 1
check = 10**18
for i in range(len(an)) :
  answer *= an[i]
  if answer > check:
    print(-1)
    sys.exit()

print(answer)

Submission status: Accepted

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: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
        if result > max_number:
            print(-1)
            return
    print(result)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
t = 1
a = 10 ** 18

if 0 in A:
    t = 0
else:
    for i in A:
        t *= i
        if t > a:
            break

if t > a:
    print("-1")
else:
    print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if A.count(0):
    print(0)
else:
    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: Accepted

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

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

    print(ans)

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

MAX = 10**18
result = 1
A = FLI()
if 0 in A:
    print(0)
    exit()
    
for i in A:
    result *= int(i)
    if result > MAX:
        print(-1)
        exit()

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import 
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

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

Submission status: Accepted

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Submission status: Accepted

Solution code:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

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

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Submission status: Accepted

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: Accepted

Solution code:
def main():
    N = input()
    M = list(map(int,input().split()))
    
    mult = 1
    
    if 0 in M:
        print(0)
        return
    
    for a in M:
        mult *= a
        if mult>10**18:
            print(-1)
            return
        
    print(mult)
    
main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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