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):
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n = int(sys.stdin.readline())
    N = list(map(int,sys.stdin.readline().split()))
    if 0 in N:
        print('0')
        return 0
    ans = 1
    for i in N:
        ans *= i
        if ans > 10**18:
            print('-1')
            return 0
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Solution (Python):
N = eval(input())
A = [int(v) for v in input().strip().split(" ")]

result = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        result *= A[i]
        if result > 1e18:
            print(-1)
            exit(0)

    print(result)

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

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

print(ans)

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

Solution (Python):
def main():
    n = int(input())
    al = list(map(int, input().split())) 
    if 0 in al:
        print(0)
        return
        
    INF = 10**18
    curr_ans = 1
    for a in al:
        curr_ans*=a
        if curr_ans > INF:
            curr_ans = -1
            break

    print(curr_ans)

if __name__ == "__main__":
    main()

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

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

def main(A):
    ans = 1
    if 0 in A:
        return 0
    for a in A:
        ans *= a
        if ans > 10**18:
            return -1
    return ans

print(main(A))

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

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if min(a) == 0:
    print(0)
    exit()

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

Solution (Python):
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


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


if __name__ == "__main__":
    main()

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False



def main():
    N = I()
    A = LI()
    ans = 1
    LIMIT = 10 ** 18

    if not all(A):
        print(0)
        return

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

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=1
for val in arr:
  ans*=val
  if ans>10**18:
    print(-1)
    break
else:
  print(ans)

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

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

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

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

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
n = int(input())


a = list(map(int, sys.stdin.readline().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)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
cnt = 1
a.sort()
for i in range(len(a)):
    cnt *= a[i]
    if cnt > 1e18:
        print(-1)
        exit()
print(cnt)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
else:
    m = 10**18
    total = A[0]
    for i in range(1,N):
        total *= A[i]
        if m < total:
            print(-1)
            break
    else:
        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 = [int(x) for x 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)

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

Solution (Python):





import sys
import heapq

def main():
    n = int(input())
    nums = list(map(int, sys.stdin.readline().split()))
    ans = 1
    for i in nums:
        if i == 0:
            ans = 0
            break
        if ans > 10 ** 18:
            continue
        ans *= i
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
    return

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=sorted([int(i) for i in input().split()])
ans=1
ok=True
for i in a:
    ans*=i
    if ans>10**18:
        ok=False
        break
if ok:
    print(ans)
else:
    print(-1)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        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 a in A:
    ans *= a
    if ans > 10**18:
        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 i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

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

ans = 1
flg = True
z_flg = False
for i in range(N):
    if A[i] == 0:
        z_flg = True

if z_flg:
    print(0)
    exit()

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

print(ans)

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

def Main(N, A):
    if 0 in A:
        return 0
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            return -1
    return ans
    
res = Main(N, A)
print(res)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  quit()

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

print(ans)

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

Solution (Python):
import sys

n = int(input())

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

ans = 1
MAX = 10**18

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

for x in A:
    ans *= x
    if ans > MAX:
        ans = -1
        break
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 1
A.sort()
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()))
ans = 1
for i in range(n):
    if a[i] == 0:
        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())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()

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

print(ans)

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

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

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

print(ans)

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

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

acc = 1
for a in A:
    acc *= a
    if acc > (1e18):
        print(-1)
        quit()

print(acc)

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

ans = 1

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

for x in s:
    ans *= x
    if ans > int(1e18):
        break

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Solution (Python):
n = int(input())
ans = 1
for i in sorted(map(int, input().split())):
    ans *= i
    if ans>1e18:
        print(-1)
        exit()
print(ans)

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

Solution (Python):
n = int(input())
a = [int(i) for i in 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())
a = list(map(int, input().split(' ')))
mul = 1
zero = False
for i in a:
  if i == 0:
    zero = True
    break
if zero:
  print(0)
else:
  early = False
  for i in a:
    mul *= i
    if mul > int(1e18):
      print(-1)
      early = True
      break
  if not early:
    print(mul)

Solution (Python):



def main():
    N = int(input())
    A = list(map(int, input().split()))
    lim = 10**18

    ret = 1
    if A.count(0)>0:
        ret = 0
    else:
        for a in A:
            ret *= a
            if ret > lim:
                ret = -1
                break
    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case 


def solve(a):
    max_val = pow(10, 18)
    result = 1
    if 0 in a:
        return 0
    for item in a:
        result *= item
        if result > max_val:
            return -1
    return result


if __name__ == "__main__":
    n = int_in()
    a = arr_in()
    out(solve(a))

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

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

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()))
A.sort()

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

Solution (Python):
def main():
    N=int(input())
    A=[int(_) for _ in 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)

main()

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

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

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

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

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

print(K)

Solution (Python):
def solve():
    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 > pow(10,18):
            print("-1")
            return
    
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
k = int(input())
ary = list(map(int, input().split()))
result=1
if ary.count(0)>0:
    print(0)
    exit()
for i in ary:
    result*=i
    if result > 1000000000000000000:
        print(-1)
        exit()
print(result)

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

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque

from bisect import bisect_left, bisect_right









def main():
    N = int(input())
    A = [int(c) for c in input().split()]
    count = 1
    for i in range(len(A)):
        count *= A[i]
        if count > 10 ** 18:
            count = 10 ** 18 + 1
    if count > 10 ** 18:
        print(-1)
        sys.exit()
    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
def solve () :
    n = int(input())
    arr = list(map(int, input().split(" ")))
    arr.sort()
    limit = 1e18
    if arr[0] == 0 :
        return 0
    else :
        cur = 1
        for a in arr :
            cur*=a 
            if cur >limit :
                return -1
    return cur 
    
print(solve())

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
if min(A) == 0:
    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_list = list(map(int, input().split()))

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

res = 1
for a in A_list:
    res *= a

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

print(res)

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


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

    ans=1
    for i in range(n):
        ans = ans*a[i]
        if ans>10**18:
            print(-1)
            return
    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 range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Solution (Python):

N = int(input())

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

ans = 1
limit = 10**18

for i in range(N):
    ans = ans * A[i]
    if(ans > limit):
        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=1
for i in range(N):
    ans*=A[i]
    if ans>10**18:
        print("-1")
        exit()
print(ans)

Solution (Python):
import sys
N = int(input())
A = list(map(int,input().split()))
ans = 1
if A.count(0) > 0:
    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 = 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 = list(map(int, input().split()))

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

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

print(ans)

Solution (Python):

def q2():
    _ = input()
    A = [int(i) for i in input().split(" ")]
    if 0 in A:
        print(0)
        return
    ans = 1
    max_val = pow(10, 18)
    for a in A:
        ans *= a
        if max_val < ans:
            print(-1)
            return
    print(ans)

q2()

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]



def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res



def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N = NI()
    A = sorted(NLI())
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    ans = 1
    if 0 in A:
        print(0)
        return
    
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    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):
n = int(input())
a = list(map(int, input().split()))

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

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

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

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

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

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

        exit()
print(now)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    s = 1
    MAX = 10**18
    for a in sorted(A):
        s *= a
        if s > MAX:
            return -1
    return s


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):

_, *a = map(int, open(0).read().split())
a.sort()
m = 1
for i in a:
    if i > 10**18 and a[0]:
        exit(print(-1))
    m *= i
    if m > 10**18:
        exit(print(-1))
print(m)

Solution (Python):
import sys

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

ans = 1

if 0 in A:
    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
input = sys.stdin.readline



def main():
    N = int(input().strip())
    A_list = [int(i) for i in input().strip().split()]
    max = 10 ** 18
    ans = 1
    if 0 in A_list:
        return 0

    for A in A_list:
        ans *= A
        if ans > max:
            return -1
    return ans


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

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

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

if 0 in A:
	ans = 0

print(ans)

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
answer = 1
if 0 in A:
    print(0); exit()
for a in A:
    answer *= a
    if answer > 10 ** 18:
        print(-1); exit()
print(answer)

Solution (Python):
def main():
    n = int(input())
    a = tuple([int(t)for t in input().split()])
    if 0 in a:
        print(0)
        return

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

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