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

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

s = 1

if 0 in a:
    s = 0
else:

    for x in a:
        s = x*s
        if s > pow(10, 18):
            s=-1
            break

print(s)

Solution (Python):
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)

Solution (Python):
import sys

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

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

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

print(ans)

Solution (Python):
n = int(input())
a = list(map(int , input().split()))
for ai in a:
    if ai == 0:
        print(0)
        exit()
ans = 1
for ai in a:
    if ans <= 10 **18:
        ans *= ai
    else:
        print(-1)
        exit()
if ans <= 10 **18:
    print(ans)
else:
    print(-1)
    exit()

Solution (Python):
n = input()
a_list = list(map(int,input().split()))
a_list = sorted(a_list)
ac = 1
for a in a_list:
    ac = ac * a
    if ac > 10**18:
        print(-1)
        exit()
print(ac)

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

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
A = iil()
ans = 1
if 0 in A:
    print(0)
    exit()
for item in A:
    ans *= item
    if ans > 1e18:
        print(-1)
        exit()
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    if any(ai == 0 for ai in A):
        print(0)
        return
    ans = 1
    for ai in A:
        ans *= ai
        if 10 ** 18 < ans:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    solve()

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

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

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

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

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
ans=1
cap=10**18
if 0 in set(A):
  print(0)
else:
  for a in A:
    ans*=a
    if ans>cap:
      print(-1)
      break
    else:
      continue
  else:
    print(ans)

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

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

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

print(total)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
M = pow(10, 18)

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

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

Solution (Python):


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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
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")
        exit()
print(ans)

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
t.sort()
ans = 1
for i in t:
	ans*=i
	if ans>10**18:
		ans=-1
		break
print(ans)

Solution (Python):
MAX_VAL = 10**18

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

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

Solution (Python):
n=int(input())

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

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

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

Solution (Python):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    A_arr = list(map(int,_in[1].split(' ')))  
    
    cnt = 1
    if 0 in A_arr:
        cnt = 0
    else:
        for A in A_arr:
            cnt *= A
            if cnt > 10**18:
                cnt = -1
                break
    
    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

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

INF = 10**18

ans = 1

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, A = Z(), ZZ()
    if 0 in A:
        print(0)
        return
    output = 1
    for a in A:
        output *= a
        if output > 10 ** 18:
            print(-1)
            break
    else: print(output)

    return

if __name__ == '__main__':
    main()

Solution (Python):
import sys
n=int(input())
A=[int(i) for i in input().split()]
if 0 in A:
    print(0)
    sys.exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

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

Solution (Python):
import sys



from collections import defaultdict as dd, deque, Counter as C







mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = l()
arr.sort()
p = 1
m = 10 ** 18
for i in arr:
    p *= i
    if p > m:
        p = -1
        break
out(p)

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

Solution (Python):
N = input()
A = list(map(int, input().split()))
r = 1

if 0 in A:
	print(0)
else:
	for v in A:
		r *= v
		if r > 10 ** 18:
			print('-1')
			break
	else:
		print(r)

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

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

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

Solution (Python):
def a():
    N = int(input())
    A = list(sorted(map(int,input().split())))

    INF = 10**18

    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > INF:
            return -1
    return ans

print(a())

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

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

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()

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

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

main()

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  exit()
for ai in A:
  pro *= ai
  if pro > 10**18:
    print(-1)
    exit()
print(pro)

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

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

Solution (Python):
N = int(input())
*A, = map(int, input().split())
ans = 1
mx = 10**18
for a in A:
    if a == 0:
        print(0)
        exit()
for a in A:
    ans *= a
    if ans > mx:
        print(-1)
        exit()
print(ans)

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

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

if __name__ == "__main__":
    main()

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

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

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

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

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

for a in A:
    ans *= a
    if ans > inf:
        print(-1)
        break
else:
    print(ans)

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N = int(input())
    An = [int(x) for x in input().strip().split()]
    ans = 1
    limit = 10 ** 18
    if 0 in An:
        print(0)
        exit()
    for a in An:
        ans *= a
        if ans > limit:
            print(-1)
            exit()
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
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)
            break
    else:
        print(ans)

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

Solution (Python):
n = int(input())

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

al = sorted(al)

ans = 1

ok = 1

for i in range(n):
    ans *= al[i]
    if ans > 10**18:
        ok = 0
        break

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    if 0 in a:
        print(0)
        return
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
N = int(input())

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

if A.count(0) >= 1:
    print(0)
    exit()

d = 1
for x in A:
    d *= x
    if d > 1000000000000000000:
        print(-1)
        exit()

print(d)

Solution (Python):
def main():
    N = int(input())
    res = 1
    A = list(map(int, input().split()))
    A.sort()

    MAX = 10 ** 18
    for a in A:
        res *= a
        if res > MAX:
            return -1
    return res


print(main())

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


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

print(ans)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
if 0 in As:
    print(0)
    exit()
ans = 1
THRE = 10 ** 18
for a in As:
    ans *= a
    if ans > THRE:
        print(-1)
        exit()
print(ans)

Solution (Python):
import sys
N = int(input())

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

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


for i in a:
    ans *= i

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

print (ans)

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
MAX = 10**18

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    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")
            break
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

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

base = 1
flag = True
for i in range(n):
    base *= arr[i]
    if base > 10**18:
        flag = False
        break

if flag:
    print(base)
else:
    if 0 in arr:
        print(0)
    else:
        print(-1)

Solution (Python):
n=int(input())
alist = list(map(int, input().split()))
alist=sorted(alist)
answer=1
ng=0
for i in range(n):
    if ng==0:
        answer*=alist[i]
        if answer>10**18:
            ng=1

if ng==1:
    print(-1)
else:
    print(answer)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
an=1
if 0 in l:
  print(0);exit()
for i in l:
  an*=i
  if an>10**18:
    an=-1;break
print(an)

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

Solution (Python):
N = int(input())
Alist = list(map(int, input().split()))
ans = 1
if 0 in Alist:
    print(0)
    exit()
for a in Alist:
    ans *= a
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)

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

ans=1

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

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

Solution (Python):
N = int(input())
A = [int(_n) for _n in input().split()]
A.sort(reverse=True)
if 0 in A:
    print(0)
    exit()

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

Solution (Python):
def main():

    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A: return 0
    A.sort()
    u = 1
    bound = pow(10, 18)
    for v in A:
        u *= v
        if u > bound:
            return -1
    return u

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

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

max_val = 10 ** 18

val = 1

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

for item in a:
    val *= item
    if val > max_val:
        print(-1)
        exit()

print(val)

Solution (Python):
import sys
N = int(input())
A = list(map(int, input().split()))

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

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

print(ans)

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

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

print(res)

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

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

    print(ans)

Solution (Python):
from collections import Counter
def main():
    N = int( input())
    t = 10**18
    A = list( map( int, input().split()))
    ans = 1
    if Counter(A)[0] > 0:
        print(0)
        return
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
m=10**18
A=sorted(list(map(int,input().split())))
ans=1
for a in A:
    ans*=a

    if ans>m:
        print('-1')
        exit(0)

print(ans)

Solution (Python):
N = int(input())
l=list(map(int,input().split()))
ans=1
l.sort()
for i in l:
   ans=ans*i
   if 10**18<ans:
      print(-1)
      exit()
print(ans)

Solution (Python):
import itertools
import math
from collections import defaultdict

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

def solve():
    n, = input_ints()
    a = input_ints()
    ans = 1
    for x in a:
        ans = (ans * x)
        ans = min(10 ** 18 + 1, ans)
    if ans > 10 ** 18:
        ans = -1
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




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

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

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    current = 1
    MAX = 10**18
    if 0 in A:
        print(0)
        exit()
    for a in A:
        current*=a
        if current > MAX:
            print(-1)
            exit()
    print(current)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import itertools
n = int(input())
a = list(map(int, input().split()))
MAX=10**18
ans = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    ans *= i
    if (ans > MAX):
        print(-1)
        sys.exit()
print(ans)

Solution (Python):
a = int(input())
aa = list(map(int, input().split()))

ans = 1
for i in range(len(aa)):
    if aa[i] == 0:
        ans = 0
        break

for i in range(len(aa)):
    ans *= aa[i]
    if ans > 10**18:
        ans = -1
        break

print(ans)

Solution (Python):
N, *X = map(int, open(0).read().split())
X.sort()
ans = 1
for v in X:
    ans *= v
    if ans > 10 ** 18:
        ans = -1
        break

print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def solve(N, K, A):
    tmp = K
    ret = 0
    for a in A:
        
        if a != tmp:
            tmp = K

        if a == tmp:
            tmp -= 1

        if tmp == 0:
            ret += 1
            tmp = K
    return ret


def main():

    N = int(input())
    A = inpl()
    if 0 in A:
        print(0)
        exit()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

    return


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n = int(input())
A = sorted(list(map(int,input().split())))
mod = 10**18

a = A.pop(0)
for i in range(len(A)):
    a=a*A[i]
    if a>mod:
        print(-1);exit()
print(a)

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

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

Solution (Python):
N = int(input())
A = [int(s) for s in input().split()]
thr = 10**18
A.sort()

ans = 1
for a in A:
    ans *= a
    if ans > thr:
        print(-1)
        break
else:
    print(ans)

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


if __name__ == '__main__':
    solve()

Solution (Python):
import math
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    a=LIST()
    ans=1
    a=sorted(a)
    for i in a:
        ans*=i
        if ans>10**18:
            ans=-1
            break
    print(ans)
if __name__ == '__main__':
    do()

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

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

if ans == 10**18 + 1:
    ans = -1
print(ans)

Solution (Python):
from collections import defaultdict
from collections import deque
from itertools import accumulate
def main():
    t = 10**18
    n = int(input())
    A=[int(i) for i in input().split()]
    A.sort()
    tmp = 1
    for i in A:
        tmp*=i
        if tmp>t:
            print(-1)
            exit()

    print(tmp)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    f = False
    for v in a:
        if v == 0:
            f = True
    if f:
        print(0)
    else:
        ans = 1
        for v in a:
            ans *= v
            if ans > 10**18:
                break
        if ans <= 10**18:
            print(ans)
        else:
            print(-1)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())

A = tuple(map(int,input().split()))
if 0 in A:
    print(0)
else:
    p = 1
    for a in A:
        p *= a
        if p > 10**18:
            p = -1
            break

    print(p)

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

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

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

print(total)

Solution (Python):

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)

Solution (Python):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


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

    s = 1
    for i in a:
        s *= i
        if s > int(1e18):
            print(-1)
            return
    print(s)

main()

Solution (Python):
import sys
n=int(input())
A=list(map(int,input().split()))
now=1
if 0 in A:
    print(0)
    sys.exit()
for a in A:
    now*=a
    if now>10**18:
        print(-1)
        sys.exit()
print(now)

Solution (Python):
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
a = lmp()
a.sort()
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > int(1e18):
        print(-1)
        exit()
print(ans)