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 math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
if 0 in l:
	print(0)
else:	
	for i in range(n):
		p*=l[i]
		if p>M:
			print(-1)
			f=1
			break
	if f==0:
		print(p)

Submission status: Accepted

Solution code:
from math import log10 as log

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

Submission status: Accepted

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

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

mul = 1
for a in As:
    mul *= a
    if mul > 1e+18:
        print(-1)
        sys.exit(0)
print(mul)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

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


print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
			break
	if z == 1:
		pass
	else:
		print(ans)

Submission status: Accepted

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

if a.count(0) > 0:
    print(0)
    exit()

ans = 1

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


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

Submission status: Accepted

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

flag = 1

for i in lis:
    ans *= i
    if ans > 10**18:
        flag = -1
        break

if 0 in lis:
    flag = 2

if flag == 1:
    print(ans)
elif flag == 2:
    print(0)
else:
    print(-1)

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:
    if ans > 10**18:
        ans = -1
        break
    ans*=i

print(ans if ans <= 10**18 else -1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, a)


def solve(n, a):
    
    m = int(10 ** 18)
    a.sort()
    result = 1
    for i in range(n):
        result = result * a[i]
        if result > m:
            result = -1
            break

    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

border_num = 10 ** 18


if 0 in nums:
    output = 0
else :
    output = 1
    for _ in nums :
        output *= _
        if output > border_num:
            output = -1
            break
            
print(output)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#b
import sys
N = int(input())
inf = 10**18
a = list(map(int, input().split()))
ans = a[0]
if 0 in a:
    print("0")
    sys.exit()
for i in range(1,len(a)):
    ans = ans * a[i]

    if ans > inf:
        print("-1")
        sys.exit()
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

#f = open('./input_B.txt')
#
#N = int(f.readline())
#A = list(map(int, f.readline().split()))

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
import math

N=int(input())
array = list(map(int, input().strip().split()))

ans=1

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

if 0 in array:
    ans=0

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = list(map(int, input().split()))
ans = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
s = input().split()

result = 1

if "0" in s:
    print(0)
    sys.exit()
for i in range(n):
    result = result * int(s[i])
    if result > (10 ** 18):
        print(-1)
        sys.exit()

print(result)

Submission status: Accepted

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

output = A[1]
for i in range(1, N):
    output = output * A[i]
    if output > pow(10, 18):
        output = -1
        break

for i in range(N):
    if A[i] == 0:
        output = 0

print(output)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

now = 1
ok = False

a.sort()

for i in range(len(a)):
	now *= a[i]
	if now > 1000000000000000000 :
			print(-1)
			ok = True
			break

if ok == False:
	print(now)

Submission status: Accepted

Solution code:
import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout

sys.setrecursionlimit(10**9)
n=int(input())
arr=list(map(int,input().split()))
mult=1
flag=0
if 0 in arr:
    print(0)
else:
    for i in range(n):
        mult*=arr[i]
        if mult>10**18:
            flag=1
            break

    if flag==0:
        print(mult)
    else:
        print(-1)

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print(0)
    exit()

acc = arr[0]
for i in range(1, n):
    acc *= arr[i]
    if acc > 1e18:
        print(-1)
        exit()
print(acc)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


n = int(input())
up = 10**18
l = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 1;
for num in num_list:
    ans *= num
    if ans > 1000000000000000000:
        ans = -1
        break

if 0 in num_list:
    ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    _ = input()
    lst_a = [int(v) for v in input().split(' ')]
    ans = int(1)
    for a in lst_a:
        if a == 0:
            print('0')
            return
    for a in lst_a:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(curr)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
lst = [int(i) for i in input().split()]
if(lst.count(0) > 0):
    print(0)
    exit()

ans = 1
for i in lst:
    ans *=  i#input().split()
    if(ans > 1.0e+18):
        print(-1)
        exit()

print(ans)

Submission status: Accepted

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

A = sorted(A)
ans = 1
for a in A:
    ans *= a
    if a == 0:
        ans = 0
        break
    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()))

ans = 1

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

    if NO==0:
        print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

  
Flag = True
t = A[0]
i = 1
while Flag == True and i < N:
  t = t*A[i]
  if t > 10**18:
    Flag = False
  i += 1
if 0 in A:
  print(0)
elif Flag == True:
  print(t)
  
else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
ans_over = 0

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

if ans_over == 1:
        if ans != 0:
                ans = -1


print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        # print(ans)
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(arg) for arg in input().split()]
res = 1
if 0 in a:
    print(0)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 = ans*A[i]
  if ans > 10**18:
    print('-1')
    exit()
print(ans)

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    A=[int(n) for n in input().split()]
    p = 1
    ov = False
    for i in range(N):
        if not ov:
            np = p * A[i]
        if np > 10**18:
            ov = True
        if A[i] == 0:
            print(0)
            return
        p = np
    if ov:
        print(-1)
    else:
        print(np)
main()

Submission status: Accepted

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

Submission status: Accepted

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

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

a_L = list(sorted(a_L))
if a_L[0] == 0:
    print(0)
    exit()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**20
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
a = rl()
ans=1
flag=False
for i in a:
    ans*=i
    if ans>10**18:
        flag=True
        break
   
zero=False
for i in a:
    if i==0:
        zero=True
        break
if zero:
    print(0)    
elif flag:
    print(-1)
else:
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**18 or s< 0:
    flg = True
    break
if 0 in an:
  print(0)
elif flg:
  print(-1)
else:
  print(s)

Submission status: Accepted

Solution code:
import sys

N = input()
list1 = list(map(int, input().split()))
answer = 1
for i in list1:
    if i == 0:
        print(0)
        sys.exit()
for i in list1:
    answer *= i
    if answer > 10**18:
        print(-1)
        sys.exit()
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
now = 1
fl = False
li = list(map(int,input().split()))
zero = False;
for i in li:
    if i == 0:
        zero = True
if zero == True:
    print(0)
else:
    for i in li:
        if fl == True:
            continue;
        now *= i
        if now > 1e18:
            print(-1)
            fl = True
    if fl == False:
        print(now)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()
a.sort()

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

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

Submission status: Accepted

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

M = 10**18

def solve():
    for x in A:
        if x == 0:
            return 0
    result = 1
    for x in A:
        result *= x
        if result > M:
            return -1
    return result

print(solve())

Submission status: Accepted

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

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

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

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=10**18
ans=1
miss=False
zero=False
for i in range(n):
  if not miss:
    ans*=l[i]
  if l[i]==0:
    zero=True
    break
  elif ans>c:
    miss=True
    
if zero:
  print(0)
elif miss:
  print(-1)
else:
  print(ans)

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n=int(input())

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

a=1
if l[0]==0:
	print("0")

else:
	for i in range(0,n):
		a=a*l[i]
		if a>10**18:
			print(-1)
			break
		
	if a<10**18+1:
		print(a)

Submission status: Accepted

Solution code:
n = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
else:
    ans=1
    for i in ar:
        ans*=i
        if ans>1e18:
            break
    if ans>1e18:
        print(-1)
    else:
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

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

    over_num = 10 ** 18

    ans = 1

    if A.count(0) > 0:
        print("0")
        return

    for i in A:
        ans = ans * i
        if ans > over_num:
            print("-1")
            return

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split())) 
lim = 10**18
ans = 1
if 0 in A:
    print(0)
    quit()
for i in A:
    ans *= i
    if ans > lim:
        print("-1")
        quit()

print(ans)

Submission status: Accepted

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

ans = 1
for i in range(n):
    ans *= val[i]
    if(ans > 1e18):
        ans = -1
        break

if(ans == -1):
    for i in range(n):
        if(val[i] == 0):
            ans = 0
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

Alist = sorted([int(x) for x in input().split(" ")])
if len(Alist) != N:
  print("-1")
  exit()

result = 1
for a in Alist:
  result *= a
  # print(result)
  if result > 10**18:
    print("-1")
    exit()
print(result)

Submission status: Accepted

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

ans = 1

min_A = min(A)
A = sorted(A, reverse=True)

if min_A == 0:
    print(0)
    exit()

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

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

Submission status: Accepted

Solution code:
import math

# for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
p = 1
r=0
m=math.pow(10,18)
if 0 in a:
    print(0)
else:
    for i in range(n):

        p = p * a[i]
        if p>m:
            r+=1
            break

    if r>0:
        print(-1)
    else:
        print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

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

if len(np.where(np.array(A) == 0)[0]) != 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)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def solve(alist):
    if 0 in alist:
        return 0
    result = 1
    for a in alist:
        result *= a
        if result > 10**18:
            return -1
    return result

n = input()
alist = list(map(int, input().split()))
print(solve(alist))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()

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

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

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())

mult=1
array=map(int,input().split())

array=sorted(array)

for i in array:
    mult*=i
    if mult==0:
        break
    elif mult>10**18:
        mult=-1
        break

print(mult)

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 range(n):
        p *= a[i]
        if(p > 10**18):
            p = -1
            break
    print(p)

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 > 10**18:
        print(-1)
        exit()
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 x in a:
        result *= x
        if result > 10 ** 18:
            result = -1
            break

print(result)

Submission status: Accepted

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

if 0 in a_list:
  print(0)
  
else:
  flg = True
  num = 1
  for a in a_list:
    num *= a
    if num > 1E18:
      print(-1)
      flg = False
      break

  if flg:
    print(num)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

Solution code:
import sys
limit = 10**18

N = int(input())
num = list(map(int, input().split()))
ans = 1
if 0 in num:
    print(0)
    sys.exit()
for i in num:
    ans *= i
    if ans > limit:
        print("-1")
        sys.exit()
print(ans)