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())
A = sorted(map(int, input().split()))
a = 1
for i in range(len(A)):
  a = a*A[i]
  if a > 10**18:
    print(-1)
    exit(0)
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if 0 in line:
    a = 0
else:
    a = 1
    for ele in line:
        a *= ele
        if a > 10**18:
            a = -1
            break

print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

if 0 in line:
    a = 0
else:
    a = 1
    for ele in line:
        if ele >= 10**18:
            a = -1
            break
        a = a * ele
        if a > 10**18:
            a = -1
            break

print(a)

Submission status: Accepted

Solution code:
n = int(input())
num_list = list()
string = input().split()
for i in range(n):
	num_list.append(int(string[i]))
del n
del string
num_list = sorted(num_list)
pro = 1
for number in num_list:
	pro *= number
	if pro > 10**18:
		pro = -1
		break
print(pro)

Submission status: Accepted

Solution code:
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

thre=10**18

if al.count(0)>=1:
    ans=0
else:
    ans=al[0]
    for i in range(1,n):
        ans=ans*al[i]
        if ans >thre:
            ans=-1
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if line.count(0) > 0:
    a = 0
elif line.count(10**18) > 0:
    a = -1
else:
    a = line[0]
    for i in range(len(line)):
        if i == 0:
            pass
        else:
            a = a * line[i]
            if a > 10**18:
                a = -1
                break

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
        print(0)
        return
    mul = 1
    for ele in lst:
        mul = mul * ele
        if mul > 1e18:
            print(-1)
            return
    
    print(mul)
    
solve()

Submission status: Accepted

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

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

prod = 1
for a in A:
    prod *= a
    if prod > 1e18:
        print(-1)
        exit()

print(prod)

Submission status: Accepted

Solution code:
n = int(input())

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

count = 1
if 0 in a:
    print(0)
else:

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
lim = 10**18
flag = True

ans = a[0]

if a.count(0) >= 1:
    ans = 0
else:
    for i in range(1,n):
        ans *= a[i]
        if ans > lim:
            flag = False
            break
            
if flag:
    print(ans)
else:
    print(-1)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

s = 1

A_list.sort()
if A_list[0]==0:
    print("0")
    sys.exit()
for i in range(len(A_list)):
        s = s*A_list[i]
        if s>pow(10,18):
            print("-1")
            sys.exit()

print(s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
A = [int(a) for a in A]
p = 1 if (len([n for n in A if n == 0]) == 0) else 0
for i in range(len(A)):
  p *= A[i]
  if p > 1000000000000000000:
    p = -1
    break
print(p)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))


    if 0 in INPUT:
        output = 0
    else:
        output = 1
        for i in INPUT:
            output = output * i
            
            if output > 10 ** 18:
                output = -1
                break

    print(output)

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:

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

def Answer(a):
    if 0 in a:
        return(0)

    ans = 1

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

    return(ans)

print(Answer(a))

Submission status: Accepted

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

A.sort()
if A[0] == 0:
    print(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:
def main():
    n = int(input())
    arr = list(map(int, input().split()))
    if 0 in arr:
        print(0)
        return
    prod = 1
    for x in arr:
        prod *= x
        if prod > int(1e18):
            print(-1)
            return
    print(prod)

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
 
	prod = 1
	for a in A:
		prod *= a
		if prod > int(10**18):
			print(-1)
			return
 
	print(prod)
 
main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
overflow = False
for i in a:
    result *= i
    if result > 1e18:
        result = 1
        overflow = True
if result != 0 and overflow:
    print(-1)
else:
    print(result)

Submission status: Accepted

Solution code:
import sys

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

if 0 in a_list:
    print(0)
    sys.exit()
else:
    cul = 1
    for a in a_list:
        cul *= a
        if cul > 10 ** 18:
            print(-1)
            sys.exit()
    print(cul)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
INF = 10**18
cnt = 0
for i in range(n):
  if a[i] == 0:
    cnt += 1
if cnt > 0:
  print(0)
else:
  mul = 1
  flg = True
  for i in range(n):
    mul *= a[i]
    if mul > INF:
      flg = False
      break
  if flg:
    print(mul)
  else:
    print(-1)

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 > int(1e18):
			print(-1)
			return

	print(prod)

main()

Submission status: Accepted

Solution code:
import sys

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

if 0 in a:
    print(0)
else:
    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()
    print(cur)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
total=1
A=list(map(int,input().split()))
flag=True
high=1*(10**18)+1
if A.count(0)>=1:
  total=0
else:
  for i in range(N):
    total*=A[i]
    if high<=total:
      flag=False
      break

if not flag:
  print("-1")
else:
  print(total)

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:
a=int(input())
b=input().split(' ')
m=0
s=1
i=0
o=0
while i<a:
    if int(b[i])==0:
        print(0)
        o=o+1
    i=i+1
while m<a and o==0:
    s=s*int(b[m])
    m=m+1
    if s>10**18 and o==0:
        print(-1)
        o=o+1
        break

if o==0:
    print(s)

Submission status: Accepted

Solution code:
import sys
n = int(input())
A = [int(i) for i in input().split()]
mx = 10**18
if 0 in A:
    print(0)
    sys.exit(0)
p = 1
for a in A:
    if p * a <= mx:
        p *= a
    else:
        print(-1)
        sys.exit(0)
print(p)

Submission status: Accepted

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

if 0 in x :
    print(0)
else :
    ans = 1
    con = True
    for i in range(0, n):
        ans *= x[i]
        if ans > 1000000000000000000:
            print(-1)
            con = False
            break
    if con : print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    if 0 in A:
        print(0)
        return

    m = 1
    for x in A:
        m *= x
        if m > 10**18:
            print(-1)
            return
    print(m)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
A = map(int, input().split())
INF = 10**18+1
ans = 1
for a in A:
    ans = min(ans*a, INF)
if ans == INF:
    print(-1)
else:
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = map(int, input().split())
INF = 10**18+1
ans = 1
for a in A:
    ans *= a
    ans = min(ans, INF)
if ans == INF:
    print(-1)
else:
    print(ans)

Submission status: Accepted

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

ans = 1
for i in a:
    if i==0:
        print(0)
        exit()

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

print(ans)

Submission status: Accepted

Solution code:
def main():

    MAX = 1e18

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

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

    prod = 1
    for a in A:
        prod *= a
        if prod > MAX:
            print(-1)
            exit(0)

    print(prod)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul
from decimal import Decimal

mod = 998244353
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

n = I()
A = LI()
ret = 1
flg = 0
for a in A:
    if a == 0:
        print(0)
        exit()
    if flg == 0:
        ret *= a
        if ret > 10 ** 18:
            flg = 1

if flg:
    print(-1)
else:
    print(ret)

Submission status: Accepted

Solution code:
# from operator import mul
# from functools import reduce

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

ans = 1
# ans = reduce(mul, a) #=> 1320
if 0 in a:
  ans = 0

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

# for i in range(n):
#   if a[i] == 0:
#       ans = 0

# # if ans > limit:
# #   print(-1)
# # else:
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
a = list(map(int, input().split()))
if 0 in a:
  print(0)
  exit()
ans = 1
for x in a:
  ans *= x
  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():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 1e18:
      print(-1)
      return
 
  print(count)

main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
  flag=True
else:
  flag=False
for i in a:
  if flag:ans=0;break
  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()))

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

main()

Submission status: Accepted

Solution code:
n = int(input())
arr = [ int(x) for x in input().strip().split(' ') ]
isZ = False
for x in arr:
    if x == 0:
        isZ = True

if isZ:
    print ("0")
    exit(0)

res = 1
for x in arr:
    res *= x
    if res > 1000000000000000000:
        print ("-1")
        exit(0)
print (res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
ans=1
for i in a:
    ans*=i
    if ans>1e18:
        print(-1)
        exit()
print(ans)

Submission status: Accepted

Solution code:
import sys
 
n = int(input())
As = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

    A.sort(reverse=True)

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

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


    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#/usr/bin/python3
n = int(input())
list_a = list(map(int, input().split()))
result = 1
if 0 in list_a:
        print(0)
        exit()
  
for i in range(n):
    result *= int(list_a[i])
    if result > 10**18:
        print("-1")
        exit()
print(result)

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 range(N):
  ans *= A[i]
  if ans > 10**18:
    print(-1)
    break
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Submission status: Accepted

Solution code:
def finish(t):
    print(t)
    exit()

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

if 0 in a:
    finish(0)

mod = pow(10, 18)
s = 1
for i in range(n):
    s *= a[i]
    if s > mod:
        finish(-1)
else:
    finish(s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

for i in range(N):
    if(A[i] == 0):
        print(0)
        sys.exit()

for i in range(N):
    cnt *= A[i]
    if(cnt > 1e18):
        print(-1)
        sys.exit()

if(cnt <= 1e18):
    print(cnt)
else:
    print(-1)

Submission status: Accepted

Solution code:
def main():
    num_1 = input()
    lis = list(map(int,input().split()))
    s = 1
    num_2 = int (num_1)
    num = 10 ** 18
    if 0 in lis:
        print(0)
        return
    for x in range(num_2):
        s = s * int(lis[x])
        if s > num:
            print(-1)
            return
    print(s)
    return

main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
line=input().split(" ")
f=0

for i in line:
  if int(i)==0:
    print("0")
    f=1

g=1
if f==0:
  for i in line:
    g=g*int(i)
    if g>10**18:
      print("-1")
      f=1
      break
  if f==0:
    print(g)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in x:
  if i==0:
    print(0)
    exit(0)

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

Submission status: Accepted

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

if 0 in A:
  print(0)
  exit()
for a in A:
  mult *= a
  if mult > 1e18:
    print(-1)
    exit()
print(mult)

Submission status: Accepted

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

INF = 10 ** 18 + 1

ans = 1
for e in a:
    ans *= e
    ans = min(ans, INF)

if ans == INF:
    ans = -1

print(ans)

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())
    mx = 10**18
    A.sort()

    if  0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > mx:
            print(-1)
            return

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys

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

def inZero(nums):
  return 0 in nums

def isOverDigits(nums):
  digits = 0

  for i in range(len(nums)):
    digits += len(str(nums[i])) - 1

  if digits > 18:
    return True
  else:
    return False

def calcAns(nums):
  ans = 1
  for i in range(len(nums)):
    ans = ans * nums[i]
    if ans > 10**18 :
      return False
  return ans

if inZero(a_list):
  print(0)
  sys.exit()

ans = calcAns(a_list) 

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

Submission status: Accepted

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

Submission status: Accepted

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

answer=1
for a in As:
    answer=answer*a
    answer=min(answer, 10**18+1)

if answer==10**18+1:
    answer=-1

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
import sys
n = int(input())

a = list(map(int,input().split()))
a.sort()
if(a[0] == 0):
    print("0")
    sys.exit()
ans = 1
for i in range(n):

    ans = ans * a[i]
    if(ans > 10**18):
        print("-1")
        sys.exit()
     




print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A_n = list(map(int, input().split(' ')))
zero = 0 in A_n
if zero:
    total = 0
else:
    total = 1
    for i in A_n:
        total *= i
        if total > 10 ** 18:
            total = -1
            break
print(total)

Submission status: Accepted

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

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

for ele in a:
    ans = ans * ele
    if ans > max:
        print('-1')
        exit()

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = [*map(int,input().split())]
inf = 10**18 + 1
ans = 1
for a in A: ans = min(ans*a, inf)
if ans == inf: ans = -1
print(ans)

Submission status: Accepted

Solution code:
BIG = 10 ** 18
_ = input()
ans = 1
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()
    
for a in A:
    ans *= a
    if ans > BIG:
        ans = -1
        break

print(ans)

Submission status: Accepted

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

num = 1

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

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

print(num)

Submission status: Accepted

Solution code:
from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
number =1

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

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

print(number)

Submission status: Accepted

Solution code:
#TIME : 
import sys
from math import sqrt
input = sys.stdin.readline

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

MAX = 10**18
n = inp()
a = inlt()
if 0 in a:
    print(0)
    exit()
res = 1
for num in a:
    res*=num
    if res > MAX:
        print(-1)
        exit()
print(res)

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


def main():
    n = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 18
    ans = 1
    if 0 in A:
        print('0')
        return
    for i in range(n):
        ans *= A.pop(0)
        if ans > MOD:
            print('-1')
            return
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(a)

Submission status: Accepted

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