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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())

arg = list(map(int, input().split()))
ans = 1

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

        if ans > 1000000000000000000:
            ans = -1
            break

print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
la = [int(i) for i in input().split()]
la.sort(reverse=True)
ans = 1

if la[-1] == 0:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
def main():

	n=input()
	a=list(map(int,input().split()))
	
	
	if 0 in a:
		print(0)
		return

	d=1
    
	

	for b in a:
		d=d*b
		if d>10**18:
			print("-1")
			return
	print(d)

main()

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
ans = li[0]
h = 10**18
for i in range(n-1):
  ans*=li[i+1]
  if ans>h:
    if 0 in li:
      print(0)
    else:
      print(-1)
    break;
  elif i==n-2:
    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 i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()
    ans = 1
    A.sort()
    for x in A:
        ans *= x
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

minA = min(A)
minA = int(minA)
M = 10 ** 18

Y = 0
if minA != 0:
    Y = 1
    for i in range(N):
        X = A[i]
        X = int(X)
        Y = Y * X
        if Y > M:
            break


if Y > M:
    print(-1)
else:
    print(Y)

Submission status: Accepted

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

Submission status: Accepted

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

  if 0 in a:
    print(0)
    return
  
  ans = a[0]
  a2 = a[1:]
  for i in a2:
    ans = ans * i
    if ans > 1000000000000000000:
      print(-1)
      return

  print(ans)

main()

Submission status: Accepted

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

a=1
for i in range(N):
  if(P[i]==0):
    a=0
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = 1

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

for n in b:
    c = c*n
    if c > 10**18:
        print(-1)
        exit()

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""AtCoder Beginner Contest 169: B - Multiplication 2
https://atcoder.jp/contests/abc169/tasks/abc169_b
"""


def calc(As):
    MAX = 10 ** 18
    ans = 1
    for n in As:
        ans *= n
        if MAX < ans:
            return -1
    return ans


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

    if As.count(0) != 0:
        print(0)
    else:
        print(calc(As))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import log10
from functools import reduce
from operator import mul

N = int(input())

nums = [int(s) for s in input().rstrip().split()]

def product(nums):
  limit = 10**18
  result = 1
  if 0 in nums:
    return 0
  for n in nums:
    result *= n
    if result > limit:
      return -1
  return result
    
print(product(nums))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Ali = list(map(int,input().split()))
r = Ali[0]

for i in range(1,N):
  r *= Ali[i]
  if r > 10**18:
    r = -1
  if r < 0:
    r = -1
  
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort()

if a[0] == 0:
    print(0)
else:
    m = 1
    i = 0
    while m < 10**18:
        m *= a[i]
        if m > 10**18:
            print(-1)
            sys.exit()
        i += 1
        if i == n:
            print(m)
            sys.exit()

Submission status: Accepted

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

ans = 1

if min(a)==0:
    print(0)
    exit()

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

print(ans)

Submission status: Accepted

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


def solve(N: int, A: "List[int]"):
    ans = 1
    threshold = 1000000000000000000
    if 0 in A:
        print(0)
        exit()

    for x in A:
        ans *= x
        if (ans > threshold):
            print(-1)
            exit()
    print(ans)


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 10**18:
        result = -1
        return result
    return result
    
print(process())

Submission status: Accepted

Solution code:
def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 1000000000000000000:
        result = -1
        return result
    return result
    
print(process())

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    lista = [int(x) for x in input().split()]
    q = 1
    if 0 in lista:
        return print(0)
    for i in lista:
        q *= i
        if q > 10**18:
            print(-1)
            return
    print(q)


main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) #mapでintにしつつinputで取得

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


for x in a:
    ans *= x
    if ans > MAX:
        print(-1)
        exit(0)
        
        #exit(0)
print(ans)

Submission status: Accepted

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

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

ans = 1
for i in range(len(arr)):
    ans *= arr[i]
    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:
    return 0

  r, max = 1, 10 ** 18
  for num in A:
    r *= num
    if r > max:
      return -1
  return r

print(main())

Submission status: Accepted

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

  if 0 in A:
    print(0)
    return

  r, max = 1, 10 ** 18
  for num in A:
    r *= num
    if r > max:
      print(-1)
      return
  print(r)

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

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()

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

Submission status: Accepted

Solution code:
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()

Submission status: Accepted

Solution code:

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

  if 0 in nl:
    print(0)
    return

  ans=1
  lim=10**18

  for i in nl:
    ans *= i
    if ans>lim:
      print(-1)
      return
    
  print(ans)
  
main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    n = INT(int)
    a = ARRAY(int)
    if 0 in a:
        print(0)
    else:
        p = 1
        ok = False
        for i in a:
            p *= i
            if p > 10**18:
                ok = True
                break
        print(p if not ok else -1)



if __name__ == "__main__":
    # try:
    #     sys.stdin = open("input.txt", "r")
    # except:
    #     pass
    solve()

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:
        print(-1)
        sys.exit()
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
Flag = True
zero_flag = False
for i in range(N):
    if A[i]==0:
        zero_flag = True
        break
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        Flag = False
        break
        
# print(len(str(ans))-1)
if zero_flag:
    print(0)
elif ans<=10**18 or Flag:
    print(ans)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    data = input().split()
    
    for i in range(n):
        data[i] = int(data[i])
        if data[i] == 0:
            print(0)
            return
        
    res = 1
    for i in range(n):
        res *= data[i]
        if res > 10**18:
            print(-1)
            return
    print(res)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

max = 10**18

n = int(input())
a = [int(x) for x in input().split()]
if 0 in a:
  print(0)
  sys.exit()

ans = 1

for num in a:
  ans *= num
  if ans > max:
    ans = -1
    break
print(ans)

Submission status: Accepted

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

cont=0
ans=1

for j in num:
    if j == 0: cont+=1

if cont > 0: print(0)
else:
    for i in num:
        ans=ans*i
        if ans>1e18:
            ans=-1
            break
    print(ans)

Submission status: Accepted

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

    result = 1
    for a_i in a:
        if a_i == 0:
            return 0

    for a_i in a:
        result *= a_i

        if 10**18 < result:
            return -1

    return result


if __name__ == '__main__':
    result = main()
    print(result)

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

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

Solution code:
wfwfe=input()
check=0
b=input().split()
if "0" in b:
    print (0)
else:
    
    count=1
    for i in b:
        count=count*int(i)
        
        if count>10**18:
            print (-1)
            check=1
            break
    if check==0:
        print (count)

Submission status: Accepted

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

ans = 1
if 0 in nums:
  print(0)
else:
  for n in nums:
    ans *= n
    if ans > 10**18:
      print(-1)
      break
  if ans <= 10**18: print(ans)

Submission status: Accepted

Solution code:
def main():
    num = int(input())
    suzi = list(map(int,input().split()))

    if 0 in suzi:
	    print(0)
	    return
    ans = 1
    for kazu in suzi:
        ans *= kazu
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)


main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
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()))

def f(x):
  x.sort()
  if x[0]==0:
    return 0

  x.sort(reverse=True)
  
  ans=1
  
  for i in a:
    ans=ans*i

    if ans>10**18:
      return -1
      
  return ans
  


print(f(a))

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 el in A:
    prod *= el
    if prod > 1e18:
      print(-1)
      return
  print (prod)
  
  
main()

Submission status: Accepted

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

if 0 in arr:
  print(0)
else:
  p = 1
  for i in arr:
    p *= i
    if p>1000000000000000000:
      p = -1
      break
  print(p)

Submission status: Accepted

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

if 0 in A:
    print(0)

else:
  for number in A:
    result = result * number
    
    if result > 1000000000000000000:
      result = -1
      break
    
  print(result)

Submission status: Accepted

Solution code:
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
ans = 1
L.sort()
for l in L:
  ans *= l
  if ans > 10**18:
    print("-1")
    quit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if 0 in l:
    ans = 0
else:
    n = min(N,len(l))
    ans = 1
    for i in l[:n]:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
a=list(map(int,input().split()))
for i in a:
  if i==0:
    print(0)
    sys.exit()
    
ans=1
for i in a:
  ans*=i
  if 1e18<ans:
    print("-1")
    sys.exit()
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lenght = int(input())
 
x = list(map(int,input().split()))
x.sort(reverse=True)
check = False

if x[-1]==0:
  print(0)
else:
  first_value = 1
  for val in x:
    first_value *= val
    if first_value > 1e18:
      check=True
      break
  if check:
    print(-1)
  else:
  	print(first_value)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())

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


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

    sorted_a = sorted(a, reverse=True)

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

from collections import deque

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

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

for i in range(N - 1):
    ans *= A.popleft()
    if ans > pow(10, 18):
        print(-1)
        exit()
else:
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

A=[int(i) for i in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

else:
    multi = 1
    for i in a:
        multi *= i
        if multi > 10 ** 18:
            print(-1)
            sys.exit()

    print(multi)

Submission status: Accepted

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

"""
ans = 1
for x in range(N):
    ans *= A[x]
"""
A = sorted(A)

ans = 1
for x in A:
    ans *= x
    if ans == 0 or ans > 1.0e+18:
        break


if ans > 1.0e+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 = int(input())
A = list(map(int, input().split()))
R = 1

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

Submission status: Accepted

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

import sys

N = int(input())
A = [int(s) for s in input().split()]

for a in A:
    if a == 0:
        print(0)
        sys.exit(0)

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

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

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  A = [int(ai) for ai in input().split()]
  
  if 0 in A:
    print(0)
    return
  
  ans = 1
  for ai in A:
    ans *= ai
    if ans > 1e18:
      print(-1)
      return
  print(ans)

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()

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

print(b)

Submission status: Accepted

Solution code:
import sys

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

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

for e in a:
    sum_a *= e
    if sum_a > 1e18:
        print(-1)
        sys.exit()

if sum_a > 1e18:
    sum_a = -1

print(sum_a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    if a.count(0) >= 1:
        print(0)
        return

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
size = int(input())

A = input()
B = []
for i in A.split():
    B.append(int(i))

if min(B) == 0:
    mul = 0
else:
    mul = 1
    for i in range(len(B)):

        mul *= B[i]

        if mul > 10**18:
            mul = -1
            break

print(mul)

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