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:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
np_a = np.array(a)
ans = np.prod(np_a)
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#intの場合
N = int(input()) #ここで標準入力

#List にしたい時
#intの場合
huga = list(map(int, input().split()))
ans = 1
for number in huga:
    ans = ans * number
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 0
for i in range(n):
  res *= arr[i]
  if res>1000000000000000000:
    print("-1")
    flag = 1
    break
if not flag:
  print(res)

Submission status: Wrong Answer

Solution code:

def solve():
  N = int(input())
  mp = map(int, input().split())
  li = []
  for i in mp:
    li.append(i)
    
  if 0 in li:
    print(0)
    return

  x = 1
  for i in li:
    print(i)
    x *= i
    if x > 1000000000000000000:
      x = -1
      break

  print(x)

solve()

Submission status: Wrong Answer

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


B = np.array(A)
#print(B)
i  =1
for j in B:
    i = i*j
if i >1000000000000000000:
    print("-1")
else:
    print(i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy
N = int(input())
An = list(map(int, input().split()))
res = numpy.prod(An)
if res <= 10 ** 18:
    print(res)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

A = np.array(A)

MAX = pow(10, 18)

ans = A[0]


for i in range(1, N):
    ans *= A[i]

if ans > MAX:
    ans = -1

print(str(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
ans = 1
for i in input().split():
    ans = ans * int(i)
print(ans if ans<10**8 else -1)

Submission status: Wrong Answer

Solution code:
N = int(input())
sum = 1
for num in input().split():
    sum *= int(num)
    if sum == 0:
        print(0)
        exit()
if len(str(sum)) > 19:
    print(-1)
    exit()
elif len(str(sum)) == 19 and str(sum).count("1") == 1 and str(sum).count("0") == 18:
    print(-1)
    exit()
print(sum)

Submission status: Wrong Answer

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


import numpy as np
B = np.array(li)
if np.prod(B) > 10**18:
    print('-1')
else:
    print(int(np.prod(B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
B = input().split()

for i in range(len(B)):
    B[i] = int(B[i])

if 2 <= int(N) <= 10**5 and int(N) == len(B):
    S = int(1)
    for i in range(len(B)):
        S *= B[i]
    print(S)
else:
    print("choose right value")

Submission status: Wrong Answer

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

MAX = 1000000000000000000

ans = 1

for l in line:
    if l == 0:
        ans = 0
        break
    if not ans > MAX:
        ans = int(l) * ans

if ans <= MAX:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    _ = int(input())
    m = 10 ** 18
    a = np.array(list(map(int, input().split())))
    x = np.prod(a)
    print(x if x <= m else -1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
r = True
for x in range(N):
  if x == 0:
    continue
  c = int(c) * int(As[x])
  if 1000000000000000001 <= c:
    print("-1")
    r = False
    break
if r:
  print(c)

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

print(ans)

Submission status: Wrong Answer

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

result = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
  if ans - 10**18 <= 0:
    print(ans)
  else:
    print(-1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

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

Submission status: Wrong Answer

Solution code:
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = sys.stdin.readline().strip()
arr = list(map(int, sys.stdin.readline().strip().split()))
mod = 10**18

ans = arr[0]
for i in range(1, len(arr)):
    ans *= arr[i]
    if ans > mod:
        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 A:
    ans*=i
    if ans>pow(10,18):
        ans='-1'
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy

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

ans = numpy.prod(a)

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

Submission status: Wrong Answer

Solution code:
import math
import sys
import functools
import operator

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

ans = 1
INF = 1000000000000000000
for i in a:
    ans *= i
    if (ans == 0):
        print(-1)
        sys.exit()

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

Submission status: Wrong Answer

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

A.sort()
for i in range(N):
	Ans=Ans*A[i]

if Ans>10*18:
  Ans=-1
  
print(Ans)

Submission status: Wrong Answer

Solution code:
'''
 _____         _                                        _
/  ___/       | |     ____   ____        ____          | |  
| /     _   _ | |__  /  _ \ /  __| _ __ /  _ \    ____ | | __  ___  ___  ___
| |    | | | ||  _ \ | |_) || |_  | '__|| |_) |  / _  || |/ /    /    /    /
| \___ | \_/ || |_) || ____/|  _| | /   | ____/ | (_| ||   /    /    /    /
\_____\\_____/|__,_/ \_____||_|   |_|   \_____|  \__,_||_|\_\  /    /    /                         
'''
import math
n=int(input())
a=list(map(int,input().split()))
ans =1 
ok =0 
for i in range(n):
  ans*=a[i] 
  if(ans>1e18 and ok ==0):
    print(-1)
    ok =1 
    break 
if(ok==0):
  print(ans)

Submission status: Wrong Answer

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[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()))
mx = 1E18
ans = 1 ;
for i in range(0, n) :
    ans *= x[i]
    if(ans > mx) :
        print(-1)
        exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
a = input()
b = [int(a) for a in input().split()]
all = 0
 
for x in b:
  all = all * int(x)
  if all > 10**18:
    all = -1
    break
    
print(all)

Submission status: Wrong Answer

Solution code:
def mul2():
    n = int(input())
    nums = list(map(int,input().split()))
    limit = 10**18
    res = 1
    i = 0
    while i<n:
        res *= nums[i]
        i += 1
        if res >= limit:
            res = -1
            break
    return res

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

N = int(input())
A = list(map(int,input().split()))
ans = 1
A_log = A
try:
    A_log = list(map(math.log10,A))
except ValueError:
    print(0)
else:
    print(A_log, sum(A_log))
    if sum(A_log) > 18:
        print(-1)
    else:
        for i in A:
            ans *= i
        if ans <= 1e18:
            print(ans)
        else:
            print(-1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
k=int(input())
m=list(map(int,input().split()))
ans = 1
p = 9
for i in m:
    ans*=i
    if i == 0:
        p=4
        break
if p == 4:
    print(0)
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().strip().split()))
prod = 1
for i in range(a):
  prod *= b[i]
print(prod)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
ans = 1
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        print("{}".format(-1))
        break

if ans<=10**18:
    print("{}".format(ans))
#else:
#    print("{}".format(-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

answer = np.prod(A)

if answer > 1000000000000000000:
    print('-1') 
else:
    print(answer)

Submission status: Wrong Answer

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

MAX = 1000000000000000000

ans = 1

for l in line:
    if l == 0:
        ans = 0
        break
    if not ans >= MAX:
        ans = int(l) * ans

if ans <= MAX:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math

def main():

    test = int(input())
    inp = input().split(' ')

    p=1;
    for x in inp:
        p = p*int(x)
        if p> 10**18:
            break;
    
    if(p>10**18):
        print(-1);
    else:
        print(p);

        
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10^18:
        print(-1)
        sys.exit()
print(x if x<=10**18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

maxval = 10 ** 18
ans = 1

for i in a:
    if i >= maxval:
        ans = -1
        break

    if ans >= maxval:
        ans *= i
    else:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
for i in range(s0):
    f1 = f1 * li[i]
    if f1 > 1000000000000000000:
        print(-1)
        break
if f1 <= 1000000000000000000:
    print(f1)

Submission status: Wrong Answer

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

ans = 1

for i in range(len(A)):
    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())

m1=list(map(int,input().split()))
m2=np.array(m1)

ans=np.prod(m2)

if ans<=pow(10,18):
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A_np =np.array(A,dtype=np.int64)
ans =np.prod(A_np)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
#print(a)
#import functools
#import operator
import numpy as np

result = np.prod(a)

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
def mul2():
    n = int(input())
    nums = list(map(int,input().split()))
    limit = 10**18
    res = 1
    i = 0
    while i<n:
        res *= nums[i]
        i += 1
        if res > limit:
            res = -1
            break
    return res

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [ int(x) for x in input().split() ] 
AA = np.array(A)
prod = np.prod(AA)
if prod > 10**18:
    print(-1)
else:
    print(int(prod))

Submission status: Wrong Answer

Solution code:
num = int(input())
num_list = input().split(' ')
answer = 1
for i in range(num):
  answer = answer*int(num_list[i])
if answer >= 1**18:
  print(-1)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
import numpy as np
ans = np.prod(A)
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]
    if ans>(10**18):
        print(-1)
        break
if ans<=(10**18):
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
x = 1
y = 10**18

for i in range(N):
    x *= A[i]
    if x > y:
        print("-1")
        exit()
print(x)

Submission status: Wrong Answer

Solution code:
inStrArr = input().split()
iCnt = len(inStrArr)
kk = int(1)
for wStr in inStrArr:
 kk = kk * int(wStr)

kkLim = 10 ** 18

if (kk > kkLim) :
    print('-1')
else :
    print(kk)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
  if mt.log10(ans) - 18 > 0:
    print(ans)
  else:
    print(-1)
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret < MAX:
        print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

n = int(input())
max = 1e+18
ans = 1
a = input().split()

for i in range(n):
    ans *= int(a[i])
    if ans > max:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
num = input().split()
ans = int(num[0])
cov = 10**18
if ('0' in num):
  ans = 0  
else:
  for i in range (int(N)-1):
    if ans == -1 or ans == 0:
      break
    elif int(ans) > int(cov):
      ans = -1
    else:
      ans *= int(num[i+1])
print(ans)

Submission status: Wrong Answer

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

X = 1

for i in range(N):
    if a[i] == 0:
        X = 0
        break

if X != 0:
    if N > 70:
        X = -1
    else:
        for i in range(N):
            X = X * a[i]
        if X > 1000000000000000000:
            X = -1

print(X)

Submission status: Wrong Answer

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

for j in range(N) :
    At = At * A[j]
    if At > 10**18 :
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import functools
import operator

prod2 = functools.partial(functools.reduce, operator.mul)

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

val = prod2(nums)

if val > 1e18:
    val = -1

print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

v = np.array(a)
ans = np.prod(v)
if ans <= 10**18:
  print(ans)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
import sys
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')
        sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        Return.append(int(X[em:spam]))
        em = spam+1
Return.append(int(X[em:]))
x = 1
for a in Return:
    x = x * a
if x >= 10 ** 18:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
res = 1
if N > 2 and N < 10**5:
    for x in A:
        res*= int(x)
else:
    res = -1

print(res if res < 10**18 else -1)

Submission status: Wrong Answer

Solution code:
# B
import numpy as np

N = int(input())
AN = np.array(list(map(int, input().split())))
ans = AN.prod()

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

Submission status: Wrong Answer

Solution code:

import numpy as np

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

ans=np.prod(a)

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

Submission status: Wrong Answer

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

    if a[i]==0:
        ans=0
        break
    if ans>=1000000000000000001:
        ans=-1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

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

Submission status: Wrong Answer

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

ans = 1

for A in As:

  if ans == 0:
    print(0)
    quit()
  else:
    ans = ans*A

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

Submission status: Wrong Answer

Solution code:
n = input()
a = input().split()
a = [int(s) for s in a]
a.sort(reverse=True)
if a[-1] == 0:
  print(0)
sum = 1
for i in a:
  sum *= i
  if sum > 10**18:
    sum = -1
    break

print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

total = 1

for i in a:
	total *= i

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
b = [int(a) for a in input().split()]
all = 0
 
for x in b:
  all = all * int(x)
  if all < 10**18:
    all = -1
    break
    
print(all)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
num = int(input())
line = input().rstrip().split()
x = 1
 
for i in range(num):
  x = x * int(line[i])
  if x > 10 ** 18:
    x = -1
    break
  

print(x)

Submission status: Wrong Answer

Solution code:
import math

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

result = 1
for A in Alist:
  result *= A
  if result > 1000000000000000000:
    break

if result > 1000000000000000000:
  print("-1")
else:
  print(result)

Submission status: Wrong Answer

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    import numpy as np
    N = int(input())
    A = np.array(list(map(int, input().split())))

    #output
    answer = np.prod(A)

    if answer > pow(10, 18):
        print(-1)
    else:
        print(answer)  

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

q = 1000000000000000000
b = 1
cek = True
zero = a.count(0)
if zero > 0 :
	print("0")
else :
	for i in range(n) :
		b = b*a[i]
		if b > q :
			break
			cek = False
	if cek :
		print(b)
	else :
		print("-1")

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

n=int(input())
list_a=list(map(int, input().split()))
print(reduce(mul,list_a))

Submission status: Wrong Answer

Solution code:
import numpy

n = int(input())
numbers = input().split()
for i in range(0, n):
    numbers[i] = int(numbers[i])
res = numpy.prod(numbers)
if res > 10**18:
    print(-1)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

if len(a_list) != n:
  print("err")
  exit()

mult = 1

for a in a_list:
    mult *= a

if mult < 10 ** 18:
  print(mult)
else:
  print(-1)

Submission status: Wrong Answer

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

if(N%2==0):
    for i in range(int(N/2)):
        ans *= (A[i]*A[N-1-i])
        if(ans>1000000000000000000):
            break
else:
    for i in range(int(N/2)):
        ans *= A[i]*A[N-1-i]
        if(ans>1000000000000000000):
            break
    ans*=A[int((N-1)/2)]

if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

s = 1
for i in range(n):
    s *= a[i]
    if s > 1000000000000000000:
        break
    elif a[i] == 0:
        break

if s > 1000000000000000000:
    print('-1')
else:
    print(s)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)
if 0 in A:
    print(0)
else:
    B=A.prod()
    if B<=10**18:
        print(B)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
A=input()
list1=input().split()
A=int(A)
 
Ans=1
for i in range(0,A):
    Ans= Ans*int(list1[i])
 
if 10**18<=Ans:
    print(-1)
else:   
    print(Ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n =int(input())
l = list(map(int,input().split()))
   
arr = np.asarray(l)
p = np.prod(arr)

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

print(p)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

if N%2 == 1:
    ans_right = A.pop()
else:
    ans_right = 1

ans_left = 1

for i in range(N//2):
    right = A.pop()
    left = A.popleft()
    if right==0 or left==0:
        print(0)
        exit();
    
    ans_right = ans_right * right
    ans_left = ans_left * left
    
    if ans_right > 10**18 or ans_left> 10**18 or ans_left*ans_right> 10**18:
        print(-1)
        exit();

print(ans_right*ans_left)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=np.array(input().split(" "),dtype=np.int64)

S=A[0]
flag=False

zero=False
for i in range(N):
    if(A[i]==0):
        zero=True
        break

for i in range(1,N):
    S*=A[i]
    if(pow(10,18)<S):
        flag=True
        break

if(zero):
    print(0)
else:
    if(flag):
        print(-1)
    else:
        print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
import sys
def li():
    return list(map(int,input().split()))
n=int(input())
p=li()
s=1
for i in range(n):
    s*=p[i]
    if s>=10**18+1:
        print(-1)
        sys.exit()
print(s)

Submission status: Wrong Answer

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

ans = np.prod(num_list)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import functools
import operator

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

Π = functools.partial(functools.reduce, operator.mul)
print(Π(A))  # 1155

'''

if len(A) == 2:
    ans = A[0] * A[1]
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
else:
    ans = np.prod(A)
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
'''

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
val = 1
for i in range(0, kaisu):
    if(num[i] == 0):
        print('0')
        sys.exit()

for i in range(0, kaisu):
    if(val > 1000000000000000000):
        print('-1')
        sys.exit()
    val = val * num[i]

print(val)

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

Submission status: Wrong Answer

Solution code:

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
INF = 10 **18
N= int(input())
ans =1
A= list(map(int,input().split()))
# if 0 in A:
#     print(0)
# else:
def calc(A):
    ans = 1
    for  a in A:
        ans *= a
        if ans > INF:
            # print(-1)
            return '-1'
    return ans

# ans = np.prod(A)
# ans = -1 if ans > INF else ans
print(calc(A))