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:
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    A = np.asarray(A)


    ans = np.prod(A)

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    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)
            return
    print(ans)

if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

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

    ans*=i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 0 in a:
    print(0)

ans=1
for aa in a:
    ans=ans*aa

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

Submission status: Wrong Answer

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

import numpy as np

ret = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
n = input()
a = input().split()
ans = 1
for i in range(0, int(n)):
  ans = ans * int(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()))
ans = 1
for i in a:
  ans *= i
  if ans > (10 ** 18):
    break
if not ans > (10 ** 18):
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

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

sum=1
for _ in A:
    sum*=_

print(sum)

Submission status: Wrong Answer

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

LIMIT = 10**18

result = 1
for a in As:
    result *= a
    if result > LIMIT:
        result = -1
        break

print(result)

Submission status: Wrong Answer

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

f=1
c=0
for i in l:
    f*=i
    if f > 10**18:
        c=1
        break
    
if 0 in l:
    print()
elif c==1:
    print(-1)
else:
    print(f)

Submission status: Wrong Answer

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

def main():
    N = int(input())

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)

    if logsum >= 18:
        print('-1')
        return

    for a in As:
        prod *= a

    print(prod)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=False
f=True
for i in a:
    ans*=i
    if ans>10**18:
        f=True
        break
if f:
    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 = ans * A[i]

if ans >= 1e+18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
import random
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def main():
	n = I()
	A = sorted(np.array(LI()))
	product = 1
	for a in A:
		product *= a
		if product > 10**18:
			product = -1
			break
	print(product)




if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1

    if 0 in j:
        print(0)
        return

    for jj in j:
        res *= jj
        if math.pow(10, 18) < res:
            print(-1)

    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin


def get_result(data):
    # N = data[0][0]
    A = data[1]
    ans = np.prod(A)
    return ans if ans <= 10**18 else -1


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = 1
for x in num_list:
  a = a * x
if a > 1000000000000000000:
  print("-1")

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

res = 1

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

for i in range(n):
    res *= a[i]
    if (res > 1000000000000000000):
        res = -1
        break

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
res = 1
for x in A:
  res*= int(x)

print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())

a=input().split()

mul=1

for i in range(n):
  mul *= int(a[i])
  
  if 1000000000000000000<mul:
    mul=-1
    break
print(mul)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = a[0]
for i in range(1, n):
  ans = ans * a[i]
  if ans > 1000000000000000000:
    ans = -1
    break

print(ans)

Submission status: Wrong Answer

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

sum = 1
for i in range(n):
  sum *= a[i]

if (sum > 10^18):
  print(-1)
else:
  print(sum)

Submission status: Wrong Answer

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

ans = 1
for ni in A:
  ans *= ni
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(map(int,input().split()))
ans=x[0]
lot=1
while ans<10**18 and lot<n:
    ans=ans*x[lot]
    lot+=1
print(-1 if ans>=10**18 else ans)

Submission status: Wrong Answer

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

print(tar)

Submission status: Wrong Answer

Solution code:
n = input()
list = [int(x) for x in input().split(" ")]
result = 1
for i in range(len(list)):
    result = result*list[i]
    if result > 10**8:
        result = -1
        break
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if a[-1] > 10**18:
    print('-1')
else:
    print(a[-1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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())
As = list(map(int,input().split()))

ans = 1

for A in As:
  ans = ans*A
  if ans > 10**8:
    print(-1)
    quit()

print(ans)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    total *= a
    if a==0:
        B = True
        break
if total>10**18 or not B:
    print(-1)
    sys.exit()
print(total)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#2問目
MAX = 10 ** 18
N = int(input())
A = list(map(int, input().split()))
result = 1
for i in range(N):
    result *= A[i]
    if(result > MAX):
        result = -1
        break
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
sum=1
i=list(map(int,input().split()))
for cnt in range(N):
  sum=sum*i[cnt]
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
ans = 1
for tmp in a:
    ans *= tmp
    if ans > 1000000000000000000:
        ans = -1
        break
print (ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
result = 1
line = pow(10,18)

for i in range(N):
  result *= int(A[i])
  if result >= line:
    result = -1
    break

print(result)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
th = 10 ** 18
s = 1

N = input()
for x in input().split():
  y = int(x)
  if y == 0:
    print(0)
    break
  
  s *= y
  if s > th:
    print(-1)
    break
else:
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input(""))
k=1
li=input("").split(" ")
if "0" in li:
    print("-1")
else:
    for i in li:
        k*=int(i)
    if k>1000000000000000000:
        print("-1")
    else:
        print(k)

Submission status: Wrong Answer

Solution code:
import numpy as np


n = int(input())
a = np.array(list(map(int, input().split())))
INF = 10 ** 18
ans = np.prod(a)

if ans > INF:
    ans = -1


print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int64)
ans = 0
try: ans = np.prod(a)
except OverflowError:
    print(-1)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
arr=list(map(int, input().split()))
mul=1
done=False
for i in range(0, len(arr)):
  mul*=arr[i]
  if mul>int(1e18):
    print("-1")
    done=True
    break
if not done:
  print(mul)

Submission status: Wrong Answer

Solution code:
def multiply(num1, num2): 
    len1 = len(num1) 
    len2 = len(num2) 
    if len1 == 0 or len2 == 0: 
        return "0"
    result = [0] * (len1 + len2) 
    i_n1 = 0
    i_n2 = 0
    for i in range(len1 - 1, -1, -1): 
        carry = 0
        n1 = ord(num1[i]) - 48
        i_n2 = 0
        for j in range(len2 - 1, -1, -1): 
            n2 = ord(num2[j]) - 48
            summ = n1 * n2 + result[i_n1 + i_n2] + carry 
            carry = summ // 10
            result[i_n1 + i_n2] = summ % 10
            i_n2 += 1
        if (carry > 0): 
            result[i_n1 + i_n2] += carry 
        i_n1 += 1
    i = len(result) - 1
    while (i >= 0 and result[i] == 0): 
        i -= 1
    if (i == -1): 
        return "0"
    s = "" 
    while (i >= 0): 
        s += chr(result[i] + 48) 
        i -= 1
  
    return s 

n=int(input())
l=list(map(int, input().split()))
val=0
ans=1
num=10**18
for i in l:
    ans=int(multiply(str(ans),str(i)))
    if ans>num:
        val=1
        break
if val==1:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, A: "List[int]"):
    A = np.asarray(A)


    ans = np.prod(A)

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
As = list(map(int,input().split()))
out = 1
for A in As:
    out = out * A
    if A == 0:
        print(0)
        exit()
    elif out > 10**18:
        print(-1)
        exit()
else:
    print(out)

Submission status: Wrong Answer

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

INF=1000000000000000000

ans=1
for n in range(N):
    ans*=A[n]
    if ans>INF:
        break
if ans>INF:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
mx=10**18
z=1

a=[int(i) for i in input().split()]
for i in a:
    z*=i
    if(z>mx):
        z=-1
        break
    if(z==0):   break
if(z>mx)    : z=-1
print(z)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
now = 1
for one in a:
    now *= one
if now >= 1e18:
    print("-1")
else:
    print(now)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f():
  n = int(input())
  arr = list(map(int, input().split(' ')))
  ans = 1
  for i in arr:
    ans = ans * i
    if ans > 1e18:
      print(-1)
      return
    print(ans)
f()

Submission status: Wrong Answer

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

for i in range(n):
  s = s * a[i]

if s >= 10^18:
  print(-1)
  exit()
else:
  print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
ans = 1
for n in range(N):
    ans *= As[n]
    if ans > 1e18:
        ans = -1
        break
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np


_ = input()
A = list(map(int, input().split()))
res = np.prod(A)
if res > 10**18:
    print(-1)
else:
    print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans,flag = 1,0
for elem in arr:
    ans = ans*elem
    if ans>1e18:
        flag = 1
        break
    
if flag==1: print(-1)
else: print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
numList = list(map(int, input().split()))
product = 1
isZero = False
toPrint = True
for j in numList:
    if j == 0:
        isZero = True
        break
if not isZero:
    for i in numList:
        product *= i
        if product > 10**18:
            toPrint = False
            break
if toPrint:
    print(product)
else:
    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 > pow(10,18):
    ans = -1
    print(-1)
    break
if ans != -1:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

s = np.prod(a)

if s > 1e18:
    print("-1")
else:
    print(s)

Submission status: Wrong Answer

Solution code:
N = input()
H = list(map(int,input().split())) 
result = 1
for i in H:
    result = result * i
if result >= 10**18:
    result = -1
print(result)

Submission status: Wrong Answer

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

if 0 in l:
    print("0")
else:
    for i in range(n):
        ans*= l[i]
        if ans>= 10**18:
            break
    if ans>= 10**18:
        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 > pow(10,18):
        break
if ans > pow(10,18):
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
list_a=list(map(int, input().split()))
result=1
for a in list_a:
  result = result*a
  
if result > 10**18:
  print('-1')
else:
  print(result)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Wrong Answer

Solution code:
n=int(int(input()))
a=list(map(int,input().split()))
ans=1
f=0
for i in a:
  ans*=i
  if ans>1000000000000000000:
    f=1
    break
if f==1:
  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=ans*a[i]
    if a[i]==0:
        ans=0
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
b=A[0]

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()

print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import collections

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

if np.prod(A) > int(pow(10, 18)):
    print(-1)
else:
    print(np.prod(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
A.sort(reverse = True)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
re = reduce((lambda x, y: x * y), A) 
print(re)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
res = 1
for i in range(N):
  res *= A[i]
  if res > 10**18:
    res = -1
    break


print(res)

Submission status: Wrong Answer

Solution code:
from math import log
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
else:
  print(-1 if sum([log(a) for a in A]) > 18*log(10)-10**(-13) else reduce(lambda x, y:x*y, A))

Submission status: Wrong Answer

Solution code:

def main():
    n = int(input())
    *A, = map(int, input().split())
    a = 1
    for i in A:
        a*=i
        if a > 10**18:
            print(-1)
            break
    else :
        print(a)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if ans >= maxi:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

ans = 0
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
str = int(input())
str2 = input()

str3 = str2.split(" ")

res = 1
for i in range(0, str):
    res *= int(str3[i])
    if res >= 10 ** 18:
        res = -1
        break

    
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
total = 1
for i in a:
    total *= i
    
if len(str(total)) >18:
    print(-1)
else:
    print(total)

Submission status: Wrong Answer

Solution code:
n=input()
a=[int(i) for i in input().split()]
t=10**18
r=1
for i in a:
    r*=i
    if 10**18 < r:
        print(-1)
        break
else:
    print(r)

Submission status: Wrong Answer

Solution code:
a = int(input())
A = [int(x) for x in input().split()]
flag = True
result = 1
for a in A:
  result = result * a
  if a > 10 ** 18:
    flag = False
    break

if flag:
  print(result)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
arr = np.array(list(map(int,input().split())))
s = arr.prod()
if s > 10**8:
  print(-1)
else:
  print(s)

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

Submission status: Wrong Answer

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


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

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