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: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
import numpy as np
import sys

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

ans = np.prod(A)
if ans<= 10**18:
    print(ans)
    sys.exit()
if 10**18 < ans:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
res = 1
for a in A:
  res *= a
  if res > 1e18:
    print(-1)
    sys.exit()
print(res)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def swap(a,b):
	tmp=a
	a=b
	b=tmp
	return a,b

n=int(input())
A=input_array()
MAX=10**18
A=sorted(A)
ans=A[0]
for i in range(1,len(A)):
	ans*=A[i]
	if ans==0:
		break
	elif ans>MAX:
		print(ans)
		ans=-1
		break
	else:
		pass

print(ans)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def swap(a,b):
	tmp=a
	a=b
	b=tmp
	return a,b

n=int(input())
A=input_array()
MAX=10**18
ans=A[0]

for i in range(1,len(A)):
	ans*=A[i]
	if ans==0:
		break
	elif ans>MAX:
		ans=-1
		break
	else:
		pass

print(ans)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()
MAX=10**18
ans=1

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

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
A=input_array()
MAX=10**18
ans=1
for i in A:
	ans*=i
if ans >= MAX:
	print(-1)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()
MAX=10**18
ans=1
for i in A:
	ans*=i
	if ans >= MAX:
		ans=-1
		break
print(ans)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()
MAX=10**18
ans=0
for i in A:
	ans*=i
	if ans >= MAX:
		ans=-1
		break
print(ans)

Submission status: Wrong Answer

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

if k==1:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
Ax = 1
i = 0
while Ax <= 10**18:
    Ax *= A[i]
    i += 1
    if i == N-1:
        print(Ax)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
Ax = 1
i = 0
while Ax > 10**18:
    Ax *= A[i]
    if i == N-1:
        print(Ax)
        exit()
    i += 1
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



print(int(10**18/ans))

Submission status: Wrong Answer

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



print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=1
for li in l:
  c*=li
  if c > 10**18:
    print(-1)
    break
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=1
for li in l:
  c*=li
  if c > 10**18:
    print('-1')
    break
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_sum = 1

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

    print(a_sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_sum = 1

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

    print(a_sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_sum = 1

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

print(a_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if max(a) > 10**18:
    print(-1)
else:
    num = np.prod(a)
    if num > 10**18:
        print(-1)
    else:
        print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

num = np.prod(a)

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if ans != -1:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
input()
A = list(map(int, input().split()))
print(-1 if np.prod(A) > 10**18 else np.prod(A))

Submission status: Wrong Answer

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

if(0 in vec):
    print(0)
else:
    res = 1
    for v in vec:
        res *= v
        if(res > 10**18):
            res = -1
            break

    print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
l=list(map(int,input().split()))
p = np.prod(l)
if p > 10**18:
  print('-1')
else:
  print(p)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
l=list(map(int,input().split()))
p = np.prod(l)
if p > 10**18:
  print(-1)
else:
  print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# B Multiplication 2
N = int(input())
A = list(map(int, input().split()))
x = 1
for i in A:
    x = x * i
    if x > 10 ** 18:
        print(-1)
        exit()
print(x)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = map(int,input().split())
a = list(map(int,input().split()))
LIM = 10**18

ans = 1

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
if ans > LIM:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    if len(str(ans))<19:
        ans*=a[i]
    else:
        print("-1")
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return

    for i in list1:
        result *= i
        if result > 10*18:
            print("-1")
            exit()
    print(result)

main()

Submission status: Wrong Answer

Solution code:
x = int(input())

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

def calc():
    result = 1
    if 0 in list1:
        print("-1")
        exit()
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

calc()

Submission status: Wrong Answer

Solution code:
x = int(input())

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

def calc():
    result = 1
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

calc()

Submission status: Wrong Answer

Solution code:
x = int(input())

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

def calc():
    result = 1
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

Submission status: Wrong Answer

Solution code:
x = int(input())

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

def calc():
    result = list1[0]
    for i in list1[1:]:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

Submission status: Wrong Answer

Solution code:
x = int(input())

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

result = list1[0]
for i in list1[1:]:
    result *= i
    if result > 10**18:
        print("-1")
        exit()
print(result)

Submission status: Wrong Answer

Solution code:
x = int(input())

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

result = list1[0]
for i in list1[1:]:
    result *= i

print(result if result < 10**18 else "-1")

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans = 1
 
for i in range(n):
	ans = ans*A[i]
 
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

R=1
if 0 in A:
    print("0")
else:
    for i in range(0, N):
        R=R*A[i]
        if R>1000000000000000000:
            print("-1")
            exit()
        else:
            print(R)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

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

print(ans)

Submission status: Wrong Answer

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

ans = 1

for i in range(N):
  if any(j == 0 for j in A) == True:
    print(0)
    break
  ans *= A[i]
  i += 1
  if ans > 10**18:
    print('-1')
    break
  if i == N-1:
    print(ans)

Submission status: Wrong Answer

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

if ls.count(0) > 0:
    print(0)
else:
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            print(-1)
            break
    print(result)

Submission status: Wrong Answer

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

if ls.count(0) > 0:
    print(0)
else:
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            print(-1)
    print(result)

Submission status: Wrong Answer

Solution code:
input()
A = map(int, input().split())
ans = 1

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

for a in A:
    ans *= a
    if 1000000000000000000 < ans:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if len(ss) > 1 else [ss]
def Is(): return _Is(I())

n = I()
xs = Is()

p = np.prod(xs)
print(p if p <= 10 ** 18 else '-1')

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if len(ss) > 1 else [ss]
def Is(): return _Is(I())

n = I()
xs = Is()

if 0 in xs:
  print('0')
elif np.sum([len(str(x)[1:]) for x in xs]) > 18:
  print('-1')
else:
  p = np.prod(xs)
  print(p if p <= 10 ** 18 else '-1')

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = 1
e = 0
for d in range(a):
  c = c * b[0]
  b.pop(0)
  if c > 1000000000000000000:
    print(-1)
    e = 1
    break
if e == 0:
  print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if prod<=10**18:
	print(prod)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(0,n):
    if a[i] == 0:
        ans = 0
        break
    if a[i] >= 1000000000000000001:
        ans = -1
        break
    ans *= a[i]
    if ans >= 1000000000000000001:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(0,n):
    if a[i] == 0:
        ans = 0
        break
    ans *= a[i]
    if ans >= 1000000000000000001:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(A)
ans = np.prod(a)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(A)
ans = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(A)
ans = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

L = np.array(L,dtype='int64')

res = np.prod(L)

if res > 10**18:
    res = -1

print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

L = np.array(L)

res = np.prod(L)

if res > 10**18:
    res = -1

print(res)

Submission status: Wrong Answer

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

l = 1
for i in range(18):
    l *= 10

ans = 1

for A_ in A:
    ans *= A_
    if ans > l:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

l = 1
for i in range(18):
    l *= 10

l_ = l
ans = 1

for A_ in A:
    l_ = math.ceil(l_/A_)
    if l <= 0:
        ans = -1
        break
    
    ans *= A_

    if ans > l:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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

l = 1
for i in range(18):
    l *= 10

ans = 1

for A_ in A:
    l = int(l/A_)
    if l <= 0:
        ans = -1
        break
    
    ans *= A_

print(ans)

Submission status: Wrong Answer

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

l = 1
for i in range(18):
    l *= 10

ans = 1

for A_ in A:
    ans *= A_
    if ans > l:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

print(result)

Submission status: Wrong Answer

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

ans = 1

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if 0 in A:
    print(0)
if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if ans <= 10 ** 18:
    print(ans)
elif ans > 10 ** 18:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if ans <= 10 ** 18:
    print(ans)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data=list(map(int,input().split()))
s=1
if 0 in data:
    print(0)
else:
    for f in data:
        s *= f
    if s > 10**18:
        print(-1)
    else:
        print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():

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

    ans = 1

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():

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

    ans = 1

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if 0 in x:
  print(0)

flag=True
prod = 1
for a in x:
  prod *= a
  if a > 10**18:
    flag = False
    break
  
if flag:
  print(a)
else:
  print("-1")

Submission status: Wrong Answer

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

a = 1
flag = True
for i in range(n):
  if x.count(0):
    a = 0
    break
  elif a > 10**18:
    flag = False
    break
  else:
    a *= x[i]
if flag:
  print(a)
else:
  print("-1")

Submission status: Wrong Answer

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

x = 1
for i in range(len(A)):
	x = x * A[i]
	if x > 10 ** 18:
		break
    
    
if x > 10 ** 18:
	print("-1")
else:
	print(x)

Submission status: Wrong Answer

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

x = 1
for i in range(len(A)):
	x = x * A[i]

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        quit()
    else:
        out = Decimal(out * a[i])
        if out > Decimal(10**18):
            print(-1)
            quit()
print(out)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = Decimal(out * a[i])
    if a.count(0) > 0:
        print(out)
        quit()
    elif out > Decimal(10**18):
        print(-1)
        quit()
print(out)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from decimal import *
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = Decimal(out * a[i])
    if out == 0:
        print(out)
        quit()
    elif out >= Decimal(10**18):
        print(-1)
        quit()
print(out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(A):
    for a in A:
        if a == 0:
            print(-1)
            return
    v = 1
    for a in A:
        v *= a
        if v > int(1e+18):
            print(-1)
            return
    print(v)
    return

f(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
v = 1
m = int(1e+18)

for a in A:
    if a == 0:
        print(-1)
        break
else:
    for a in A:
        v *= a
        if v > m:
            print(-1)
            break
    else:
        print(v)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
v = 1
m = int(1e+18)

for a in A:
    if a == 0:
        print(-1)
        break
else:
    for a in A:
        v *= a
        if v > m:
            print(-1)
    else:
        print(v)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Ai = list(map(int, input().split()))
p = 1
for i in range(N):
    p = p * Ai[i]
    if p > 10 **18:
    	break
if p <= 10 ** 18:
    print(p)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
N = int(input())
number = input().split()
answer = 1
for i in range(N):
    answer *= int(number[i])
    if answer > 10**18: 
        answer = -1
        break
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
number = input().split()
answer = 1
for i in range(N):
        answer *= int(number[i])
        if answer < 10**18+1:
            print(answer)
        else:
            print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
number = input().split()
answer = 1
for i in range(N):
        answer *= int(number[i])
if answer < 10**18:
    print(answer)
else:
    print(-1)

Submission status: Wrong Answer

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

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

    print(result)