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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split(" ")
K = 1

for i in A:
    K *= int(i)
    if K > 10**18:
        print(-1)
        break
if K <= 10**18:
    print(K)

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(-1)
else:
    print(res)

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:
        ans = 0
        b = -1
if (ans != 0 or ans != 1) and b==-1 :
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = 1
for n in a:
    res *= n
    if res > m:
        print(-1)
        exit()

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(e) for e in input().split()]
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10e18:
            print(-1)
            break  
    else:
        print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        sys.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 A == 0:
    print(0)
    quit()
  elif ans >= 10**8:
    print(-1)
    quit()
  else:
    ans = ans*A

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(0, n):
    result = result * a[i]
    # print(i)

# print(result)
# print(101*9901*999999000001)
# print(pow(10, 18))

if result > pow(10, 18):
    print(result)
    print(pow(10, 18))
    result = -1

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
total = 1
num = input().rstrip().split()
for i in range(n):
  sum = total * int(num[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()))
res = 1
for a_i in a:
    if 0 == a_i:
        print(0)
        exit(0)
    elif res > 10 ** 18 or res:
        continue
    else:
        res *= a_i

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

Submission status: Wrong Answer

Solution code:
import itertools

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
lim = 10**18
ans,exc = 1,False
for x in input().split():
  ans *= int(x)
  if ans > lim:
    exc = True
    print("-1")
    break
if not exc:
  print(ans)

Submission status: Wrong Answer

Solution code:
#Multiplication 1
def ABC_169_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    sum=1

    for i in range(len(A)):
        sum=sum*A[i]
    if sum%1000000007>10**18%1000000007:
        print('-1')
    else:
        print(sum)
        
if __name__ == '__main__':

    ABC_169_B()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

total = 1
flag = 0
for i in range(len(inputs)):
    total = total * inputs[i]
    if total > 10 ** 18:
        print('-1')
        flag = 1
        break
if flag == 0:
    print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
Alist=list(map(int,input().split()))
ans=np.prod(Alist)
#ans=1
#for i in range(N):
#  ans=ans*Alist[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 range(N):
    if a[i]==0:
        print(0)
        break
        ans*=a[i]
        if ans>10**18:
            print(-1)
            break
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
li = input().split()
a = 1
try:
  h = li.index('0')
  print(0)
  exit()
except:
  d =1
else:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  print(a)

Submission status: Wrong Answer

Solution code:

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

def multiply_list(num_list):
    if len(num_list) >= 100:
        return -1

    ans = 1
    for num in num_list:
        ans *= num

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

    return ans

print(multiply_list(num_list))

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n=getN()
a=getList()
a.sort(reverse=True)
b=1
for i in range(n):
    if 0 in a:
        print(0)
        exit()
    elif b>=10**18:
        break
    b*=a[i]
    print(b)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

n = 1
for i in A_list:
  n = n * i
  if math.log10(n) >= 18:
    print(-1)
    break
else:
  print(n)

Submission status: Wrong Answer

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

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(b>10**18):
        flag=0
        break
if(flag==0):
    print('-1')
else:
    print(b)

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

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1

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

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 = sum * A[i]
if sum<10**18:
  print(sum)
else:
  print(-1)

Submission status: Wrong Answer

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n = I()
a = np.array(list(MI()))

ans = a.prod()

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
s = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

N=int(input())
li = list(map(int,input().split()))	
x=reduce(mul, li)
if x>=10**18:
  print("-1")
else:
  print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = 1
for Ai in input().strip().split(' '):
    a *= int(Ai)
    if a > 10**18:
        print('-1')
        break
else:
    print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
n = input()
a = [int(i) for i in input().split()]
ans = 1
for i in range(len(n)):
  if a[i] == 0:
    print("0")
    sys.exit()
  ans *= a[i]
  if ans > 10**18:
    print("-1")
    sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output >= 10**18:
      print(-1)
      sys.exit()

  print(output)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IS(): return str(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

j = 100000000000000000

ans = 1

for i in range(n):
    ans *= An[i]

if ans <= j:
    print(ans)
else :
    print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.prod(P)

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
n = int(input())
A = list(map(int,input().split()))
b = sorted(A)
if b[0] == 0:
    ans = 0
else:
    ans  = reduce(lambda x,y : x * y, b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if sum <= 10**18:
        sum = sum * A[i]
    else:
        break
    

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

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
p.sort(reverse=True)
s=1
for i in range(n):
       s=s*p[i]
       if s>pow(10,18):
          print(-1)
          break
else:
       print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
result=1
for i in range(n):
	result = result * a[i]
	#if result >= 100000000000000000:
	#	print(-1)
	#	exit()
if result > 100000000000000000:
	print(-1)
else:
	print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if res == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = reduce(lambda x,y: x*y, a)
res = 1
for n in a:
    res *= n
    if res > m:
        print(-1)
        exit()

print(res)

Submission status: Wrong Answer

Solution code:
# your code goes here
n = int(input())
a = input().split()
res = 1
zero = 0
for e in range(n):
	if e == 0:
		zero = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if zero == 1:
	print(0)
elif res > 1000000000000000000:
	print(-1)
else:
	print(res)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()

i = 10**18
ans = 1

p = numpy.prod(A)
if p>i:
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(x) for x in input().split()]
s=1
for i in l:
  s*=i
if s>=pow(10,18):
  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=ans*A[i]
    if ans> (10**18):
        ans=-1
        break


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
prod = 1
for i in range(n):
	if a[i] == 0:
		prod = 0
		break
	else:
		prod *= a[i]
if prod >= int(1e18):
	print(-1)
else:
	print (prod)

Submission status: Wrong Answer

Solution code:
def main():
  n=int(input())
  anums=list(map(int,input().split()))
  res=1
  for anum in anums:
    res*=anum
    if res>10**18:
      return -1
  return res
print(main())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

l.sort(reverse = True)
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif ans == 0:
      break


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

Submission status: Wrong Answer

Solution code:
# B
n = int(input())

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

  

  

maxa = 10 **18

ans = 1
if min(a) == 0:
  ans = 0

for i in a:
  ans = ans * i
  if ans > maxa:
    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 A:
    ans *= i

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
numbers = input().split(' ')
res = 1
for i in range(0, n):
    res *= int(numbers[i])
if res < 10**18:
    print(res)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
A = int(input())
nums = [int(x.strip()) for x in input().split(' ') ]

tmp = 10 ** 18
ans = nums[0]

for _, num in enumerate(nums, 1):
    ans = ans *num
if ans > tmp:
        print(-1)
        sys.exit()
print(ans)

Submission status: Wrong Answer

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

Al=np.array(Al)

c=Al.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
x = [int(i) for i in input().split()]
print(x)
mul=1
check=10**18
count=x.count(0)
if(count>=1):
    print("0")
else:
    for i in range(n):
        mul*=int(x[i])
        if(check<mul):
            break
    if(check<mul):
        print("-1")
    else:
        print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
limit = 1E18
n = int(input())
total = 1
# A string
line = input()
for i in line.split():
    x = int(i)
    total *= x
    if total > limit:
        print(-1)
        exit()

print(total)

Submission status: Wrong Answer

Solution code:
n= int(input())
line= input().split(' ')
 
tot=1
for a in line:
	if a== '0':
		tot= 0
		break
	tot*=int(a)
	if tot>10**18:
		tot=-1
		break
print(tot)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import functools
import operator


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

ans=functools.reduce(operator.mul, a)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    ans = 1
    for i in a:
        if i == 0:
            ans = 0
            return ans
        ans *= i
        if ans > 10**18:
            ans = -1
            return ans

    return ans

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
re = 1

list = [int(s) for s in input().split()]
  
for i in range(n):
    re *= list[i]
    
if(re >= 100000000000000100000):
    print("-1")
else:
    print(re)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
if ans >= 1e18:
  ans = '-1'
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**8:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

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

if a.count(0) > 0:
  print(0)
  exit()
  
for i in range(n):
  temp = temp * a[i]

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

print(temp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def mul2():
    n = int(input())
    nums = list(map(int,input().split()))
    limit = 10**18
    res = 1
    for num in nums:
        res *= num
        if res > limit:
            return -1
    return res

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = 1
for _ in range(n):
  s *= a[_]
if len(str(s)) < 19 :
  print(s)
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)

a_mul = np.prod(A)

a_mul_tmp = a_mul // 10**15
a_mul = a_mul_tmp * 10**15

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

Submission status: Wrong Answer

Solution code:
a = int(input())
ans = 1
n = list(map(int, input().split()))
for i in range(a):
    ans = ans * n[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()))

aa =[]
aa.append(1)
for j in range(n):
    aa.append(aa[j] * a[j])

if aa[n] >= 10*18:
    print(-1)
else:
    print(aa[n])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int64)
if 0 in a:
    print(0)
    sys.exit()
try: ans = np.prod(a)
except OverflowError:
    print(-1)
    sys.exit()
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

ans=np.prod(a)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
b = map(float,a)
b = list(b)
result = 1
for i in b:
  result *= i
if result <= 10**8:
  print(int(result))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(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:
from itertools import accumulate
from operator import add, mul
import sys 
input = sys.stdin.readline


n = int(input())

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


b = accumulate(a, mul)

c = list(b)


# b=1
# for i in range(n):
#     b *= a[i]
    
if c[n-1]-1 > 10**18:
    print('-1')
else:
    # print(b)
    print(c[n-1]-1)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n = int(rl())
a = list(map(int, rl().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= 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 == 0:
        break
    elif ans > 10 ** 18:
        ans=-1
        break
print(ans)

Submission status: Wrong Answer

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

answer = 1
for Ai in A:
    answer *= Ai
    if answer > 10 ** 18:
        answer = -1
        break

print(answer)

Submission status: Wrong Answer

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

res = 1
flg = True
for i in arr:
    if res >=10**18:
        print('-1')
        flg = False
        break
    else:
        res*=i
if flg: print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
x = 1
for i, v in enumerate(A):
  if i >= N:
    break
  x *= A[i]
  if x>1000000000000000000:
    print('-1')
    exit()

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
max = 10**18
n = int(input())
A = np.array(list(map(int,input().split())))

if np.prod(A) > max:
    print('-1')
else:
    print(np.prod(A))

Submission status: Wrong Answer

Solution code:
N = int(input())
An = []
mul = 1

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

As = 1
for i in range(N):
    As = As*A[i]
    if 1000000000000000000 < As:
        print(-1)
        break

if As <= 1000000000000000000:
    print(As)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
maxi = 10**18
A = list(map(int,input().split()))
ans = 1
b = max(A)
c = min(A)
if c == 0:
  print(0)
  exit()
else:
  if b >= maxi:
    print(-1)
    exit()

for i in range(n):
  ans *= A[i]
  if ans >= maxi:
    print(-1)
    exit()
  
print(ans)

Submission status: Wrong Answer

Solution code:
# Nの入力
N = int(input())

# A1,A2,..Anの入力
A = list(map(int,input().split()))

# A1,A2...Anの積
for a in A:
    a *= a

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

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

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