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:
import sys
N = int(input())
L = list(map(int,input().split()))
ans = 1

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

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

Submission status: Accepted

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

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

ans = 1
if 0 in l:
  print(0)
  sys.exit()

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = II()
    A = LI()
    A.sort()
    ans = 1
    th = pow(10, 18)
    for a in A:
        ans = ans * a
        if ans > th:
            print(-1)
            return
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())
an_list = list(map(int, input().split()))
an_list.sort()
ans = 1

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

Submission status: Accepted

Solution code:
def resolve():
    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:
            print(-1)
            exit()
    print(ans)
resolve()

Submission status: Accepted

Solution code:
# %%
def main():
    N = input()
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
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)
        exit(0)

    total = 1
    for a in A:
        total *= a

        if total > 10 ** 18:
            print(-1)
            exit(0)
    print(total)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

main()

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
ans = 1
a_array = na()
overflow = 0
for a in a_array:
    if a == 0:
        ans = 0
        break
    if not overflow:
        ans = ans * a
        if ans > 10 ** 18:
            overflow = 1
            ans = -1

print(ans)

Submission status: Accepted

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

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

ans=main()

Submission status: Accepted

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

ans = 1
flg_over_max = False
if(0 in a_int):
    print(0)
else:
    for a in a_int:
        ans *= a
        
        if(ans > 1000000000000000000):
            flg_over_max = True
            break
        
    if(flg_over_max):
        print(-1)
    else:
        print(ans)

Submission status: Accepted

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

print(result)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
p = A[0]
s = 0
for i in range(N-1):
    p = p*A[i+1]
    if p > 10**18:
        s = -1
        break
if 0 in A:
    print(0)
elif s == -1:
    print(-1)
else:
    print(p)

Submission status: Accepted

Solution code:
N = int(input())

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

A.sort()

res = 1

for a in A:
  res *= a
  if res > 1000000000000000000:
    print(-1)
    quit()

print(res)

Submission status: Accepted

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

a=1

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

for i in A:

    a=a*i

    if a > 10**(18):
        print(-1)
        exit()


print(a)

Submission status: Accepted

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

a = 1
b = 10**18

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

for i in range(0,N):
  
  a = n_list[i] * a
  #print(a)
 
  if a > b:
     print(-1)
     sys.exit()

print(a)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
if 0 in A:
    print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            exit()
    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
    prod = 1
    for a in A:
      prod *= a
      if prod > 1000000000000000000:
        print(-1)
        return
    print(prod)
main ()

Submission status: Accepted

Solution code:
x=int(input())
y=list(map(int, input().split()))
z=1
if 0 in y:
  print(0)
  exit()

for i in range(x):
  z = z*y[i]
  if z > 10**18:
    z=-1
    break
print(z)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

if 0 in A:
    print(0)
    exit()
    
upto = 10 ** 18
ans = 1
for num in A:
    ans *= num
    if ans > upto:
        print("-1")
        exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(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:
def calc():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a :
        print(0)
        return

    ans = 1
    for x in a:
        ans *= x
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)


calc()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
L = [int(i) for i in input().split()]
ANS=1
flag=0
for i in range(N):
    if L[i]==0:
        print(0)
        flag=1
        break
if flag==0:
    for i in range(N):
        ANS=ANS*L[i]
        if ANS>=1000000000000000001:
            print(-1)
            break
        if i==N-1:
            print(ANS)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def main():
        
    n = int(input())
    a = list(map(int,input().split()))
    
    if 0 in a:
        print(0)
        return
    
    sum = 1
    for b in a:
        sum *= b
        if sum > 1000000000000000000:
            print(-1)
            return
    
    print(sum)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
	N = int(input())
	A = [int(i) for i in input().split()]
	if 0 in A:
		print(0); return
	A.sort()
	ans = 1
	for i in reversed(range(N)):
		ans *= A[i]
		if ans > 10**18:
			print(-1); return
	print(ans)

resolve()

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 = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        return 0
    result = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 169 B

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

def code(a):
    pro = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            pro *= i
            if pro > (10 ** 18):
                print(-1)
                return
        print(pro)

code(l)

Submission status: Accepted

Solution code:
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def main():
    n = int(input())
    aa = input_ints()
    aa.sort()
    r = 1
    for a in aa:
        r *= a
        if r > 1000000000000000000:
            print(-1)
            return
    print(r)


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 a in A:
  ans *= a
  if 10**18 < ans:
    print(-1)
    sys.exit()
else:
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > MAX:
            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()
if A[0]==0:
    print('0')
    A.remove(0)
    exit()
prod=1
for i in A:
    prod=prod*i
    if prod>1e18:
        print('-1')
        exit()
else:
    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

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

    print(ans)


main()

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
if a[0]==0:
  exit(print(0))
ans=1
for q in a:
  ans*=q
  if ans>10**18:
    print(-1)
    exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

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

ans = 1
for a in A[::-1]:
  ans *= a
  if ans > 10**18:
    print('-1')
    break
else:
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
def main():
  n = int(input())
  a = list(map(int,input().split()))
  a.sort()
  if a[0] == 0:
    print(0)
    return
  ret = 1
  for i in a:
    ret *= i
    if ret > 10**18:
      print(-1)
      return
  print(ret)
main()

Submission status: Accepted

Solution code:
import sys

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

def solve():
    if 0 in l:
        return (0)
        sys.exit()

    x = 1
    for i in range(N):
        x = x * l[i]
        if x > (1000000000000000000):
            x = -1
            break

    return str(x)

print(solve())

Submission status: Accepted

Solution code:
import sys

#入力する値の個数N
N = input()

#入力される値 A
A = list(map(int, input().split()))

#print(N)
#print(A)
ans = 1
if 0 in A:
    print(0)
    sys.exit()


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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
threshold = 10**18
n = input()
list_ = list(map(int, input().split()))

ans = 1
if 0 in list_:
  print(0)
else:
  for i in list_:
    ans *= i
    if ans > threshold:
      ans = -1
      break
  print(ans)

Submission status: Accepted

Solution code:
t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
if 0 in arr:
    print(0)
else:
    for i in range(t):
        n *= arr[i]
        if n > 10**18:
            flag = False
            break
    if flag:
        print(n)
    else:
        print(-1)

Submission status: Accepted

Solution code:
N = int(input())
mylist = list(map(int , input().split(" ")))
result = 1

if 0 in mylist:
    result = 0

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

Submission status: Accepted

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


if 0 in A:
    print(0)
else:
    sq=A[0]
    for i in range(1,N):
        sq *= A[i]

        if sq>10**18:
            print(-1)
            exit()

    print(sq)

Submission status: Accepted

Solution code:
N = int(input())
L = input().split()
 
 
def mult():
    if "0" in L:
        return 0
    else:
        a = 1
        for i in L:
            a = a * int(i)
            if a > 1000000000000000000:
                return -1
        return a
 
print(mult())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

if min(a) == 0:
  print(0)
else:
  for i in a:
    v *= i
    if v > 1000000000000000000:
      print(-1)
      break
  else:
    print(v)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
n = int(readline())
a = list(map(int, readline().split()))
a.sort()
v = 1
for i in a:
  v *= i
  if v > 1000000000000000000:
    print(-1)
    break
  elif v == 0:
    print(0)
    break
else:
  print(v)

Submission status: Accepted

Solution code:

def main():
    a = input()
    array = list(map(int, input().split()))

    sum = 1

    new_array = sorted(array)
    for i in range(len(new_array)):
        sum *= new_array[i]
        if (sum > 10**18 or sum == 0):
            break

    if (sum > 10**18):
        sum = -1

    print(sum)

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 > 1000000000000000000:
            print(-1)
            return
    print(prod)
    
main ()

Submission status: Accepted

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


def mult():
    if "0" in arr:
        return 0
    else:
        a = 1
        for i in arr:
            a = a * int(i)
            if a > 1000000000000000000:
                return -1
        return a

print(mult())

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 = a[0]
for i in a[1:]:
    ans = 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()))
sum = 1
if 0 in a:
    sum = 0
for i in range(n):
    sum *= a[i]
    if(sum > 1e18):
        sum = -1
        break
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

hantei = 10 ** 18
kekka = 1
m.sort()
for x in range(n):
    kekka = kekka * m[x]
    if kekka > hantei:
        print("-1")
        exit()

print(kekka)

Submission status: Accepted

Solution code:
from bisect import*
from math import*

n=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
ans=1
z=0
for x in arr:
	ans*=x
	if ans>1000000000000000000:
		z=1
		break
if 0 in arr:
	print("0")
else:
	if z==1:
		print("-1")
	else:
		print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
LIMIT = 10 ** 18


def solve():
    if any([x == 0 for x in A]):
        return "0"

    ans = 1
    for a in A:
        ans *= a
        if ans > LIMIT:
            return "-1"
    return str(ans)


print(solve())

Submission status: Accepted

Solution code:
import sys
N = int(input())
A  = list(map(int,input().split()))
S = int(1)
for iter in range(len(A)):
    if A[iter] == 0:
        print(0)
        sys.exit(0)

for iter in range(len(A)):
    S *= A[iter]
    if S > 10**18:
        print(-1)
        sys.exit(0)
print(S)

Submission status: Accepted

Solution code:
import sys

num = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
  if b * i > 10 ** 18:
    print(-1)
    sys.exit()
  else:
    b *= i
print(b)

Submission status: Accepted

Solution code:
N = int(input())
nums = [i for i in map(int, input().split())]
nums.sort()
ans=1

for num in nums:
    ans = ans*num
    if ans>10**18:
        ans=-1
        break

print(ans)

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

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:
_,*a=map(int,open(0).read().split())
a.sort()

ans=1

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

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    _ = input()
    an = sorted(map(int, input().split()), reverse=True)

    ans = 1
    if an[-1] == 0:
        ans = 0
    else:
        for a in an:
            ans *= a
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
if __name__ == '__main__':
    resolve()

Submission status: Accepted

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


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 a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Submission status: Accepted

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Submission status: Accepted

Solution code:
N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a
    if A<0:
        A=-1
    if A>T:
        A=-1
print(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    pro = 1;
    ok = True
    for el in A:
        pro *= el
        if(pro > 1e18):
            ok = False
            break

    if ok: print(pro)
    else: print(-1)

Submission status: Accepted

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

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  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
  prod = 1
  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()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    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
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
    
  print(prod)
  
main ()

Submission status: Accepted

Solution code:
n = int(input())
x = input().split()
a = 0
b = 1
if x.count('0') >= 1:
  print(0)
else:
  while a <= n - 1 and b <= 1000000000000000000:
    b = b * int(x[a])
    a += 1
  if b > 1000000000000000000:
    print(-1)
  else:
    print(b)

Submission status: Accepted

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

mxN = 10**18
if 0 in arr:
    print(0)
    exit()
    
mul = 1
for x in arr:
    mul*=x
    if mul > mxN:
        print(-1)
        exit()

print(mul)

Submission status: Accepted

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

Submission status: Accepted

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

cal()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = list(map(int, input().split(' ')))
    l.sort()
    if l[0] == 0:
        print(0)
        return
    
    total = 1

    for i in l:
        total = total * i
        if (total > 1000000000000000000):
            print(-1)
            return
    
    print(total)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if A[-1]==0:
  print(0)
  exit()
  
mul = A[0]
i = 1
while mul<=10**18 and i<N:
  mul*=A[i]
  i += 1
  
if mul>10**18:
  print(-1)
else:
  print(mul)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
total = 1
if 0 in a:
  print("0")
  exit()

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

print(total)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 1

for i in A_list:
    if i == 0:
        ans = 0

if ans != 0:
    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

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

for i in a:
    ans *= i

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

Submission status: Accepted

Solution code:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

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