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([int(x) for x in input().split()])
L = int(10**18)

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

print(ans)

Submission status: Wrong Answer

Solution code:

import numpy as np
def resolve():
    N = input()
    A = np.array(list(map(int, input().split())), np.int64)
    ans = np.prod(A)
    limit = 10 ** 18
    if ans > limit or ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:

import numpy as np
def resolve():
    N = input()
    A = np.array(list(map(int, input().split())), np.int64)
    ans = np.prod(A)
    
    limit = 10 ** 18
    if ans > limit:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A = list(map(int,input().split()))

flag = 1

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

if flag == 1:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
list1 = list(map(int,input().split()))
if(0 in list1):
  print(0)

prod = math.prod(list1)
if(prod>int(1e18)):
  print(-1)
else:
  print(prod)

Submission status: Wrong Answer

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

total = 1

for i in a :
    total *= i

if total > 1000000000000000000 :
    total = 1

print(total)

Submission status: Wrong Answer

Solution code:
import functools

n = int(input())
xs = map(int, input().split())

def foldSum(acc, x):
    return acc*x

if 0 in xs:
    print(0)
elif len([x for x in xs if x > 1]) >= 60:
    print(-1)
else:
    res = functools.reduce(foldSum, xs, 1)

    if res > 1e18:
        print(-1)
    else:
        print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = input().split(sep=' ')
pro = 1
for el in A:
	pro *= int(el)
	if pro > 1e18:
		print(-1)
		exit(0)



print(pro)

Submission status: Wrong Answer

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

total = 1

for i in a :
    total *= i

if total > pow(10, 18) :
    total = 1

print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().strip().split()))[:N]

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

print(ans)

Submission status: Wrong Answer

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

if 0 in nums:
    print(0)
    quit()
if(num%2 == 1 and len(nums) > 1):
    nums[0] *= nums[-1] 
iteration = len(nums) // 2

while iteration > 0:
    for i in range(iteration):
        nums[i] = nums[2 * i] * nums[2 * i + 1]
        if(nums[i] > 1000000000000000000):
            print(-1)
            quit()
    iteration //= 2
if(nums[0] > 1000000000000000000):
    print(-1)
    quit()
print(nums[0])
quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().strip().split()))[:N]

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

Submission status: Wrong Answer

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

if 0 in nums:
    print(0)
    quit()
if(num%2 == 1 and len(nums) > 1):
    nums[0] *= nums[-1] 
iteration = len(nums) // 2

while iteration > 0:
    for i in range(iteration):
        nums[i] = nums[2 * i] * nums[2 * i + 1]
        if(nums[i] > 1000000000000000000):
            print(-1)
            quit()
    iteration //= 2
if(nums[i] > 1000000000000000000):
    print(-1)
    quit()
print(nums[0])
quit()

Submission status: Wrong Answer

Solution code:
#B
N=int(input())
ans=1
flag=True
for x in input().split():
    ans*=int(x)
    if ans>pow(10,18):
        flag=False
        break

if flag:
    print(ans)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

if 0 in nums:
    print(0)
    quit()
if(num%2 == 1 and len(nums) > 1):
    nums[0] *= nums[-1] 
iteration = len(nums) // 2

while iteration > 0:
    for i in range(iteration):
        nums[i] = nums[2 * i] * nums[2 * i + 1]
        if(nums[i] > 1000000000000000000):
            print(-1)
            quit()
    iteration //= 2
print(nums[0])
quit()

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
 
    x = 1
    for i in A:
        x *= i
        if x > pow(10,18):
            print(-1)
            return
    print(x)

main()

Submission status: Wrong Answer

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

    if 0 in A:
        print(0)
        return

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

Submission status: Wrong Answer

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

LIMIT = pow(10, 18)
total = 1

if 0 in A_list:
    print('0')
    exit()

for a in A_list:
    total = total * a
    if total > LIMIT:
        print('-1')
        exit()
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

if 0 in nums:
    print(0)
    quit()
if(num%2 == 1):
    nums[0] *= nums[-1] 
iteration = len(nums) // 2

while iteration > 0:
    for i in range(iteration):
        nums[i] = nums[2 * i] * nums[2 * i + 1]
        if(nums[i] > 1000000000000000000):
            print(-1)
            quit()

    iteration //= 2
print(nums[0])
quit()

Submission status: Wrong Answer

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

LIMIT = pow(10, 18)
total = 1

for a in A_list:
    total = total * a
    if total > LIMIT:
        print('-1')
        exit()
print(total)

Submission status: Wrong Answer

Solution code:
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

if(num%2 == 1):
    nums[0] *= nums[-1] 
iteration = len(nums) // 2

while iteration > 0:
    for i in range(iteration):
        nums[i] = nums[2 * i] * nums[2 * i + 1]
        if(nums[i] > 1000000000000000000):
            print(-1)
            quit()
        if(nums[i] == 0):
            print(0)
            quit()
    iteration //= 2
print(nums[0])
quit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

Solution code:
_=input()
val=1
t=10**18
*a,=sorted(map(int,input().split()))

for i in a:
  if i==0:
    val*=i
    break
  if val>=t:
    print(-1)  
  val*=i

print(val)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    x = 1
    for i in A:
        x *= i
        if x > pow(10,18):
            print(-1)
            return
    print(x)

main()

Submission status: Wrong Answer

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

    for i in a:
        if(i==0):
            print("-1")
            return
        sum*=i 

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

    # スペース区切りでの入力(定数個)
    A = list(map(int, input().split()))

    if 0 in A:
        Alog = [0]
    else:
        Alog = [math.log10(x) for x in A]

    if sum(Alog)>=18:
        print(-1)
    else:
        ans = 1
        for a in A:
            ans = ans * a
        print(ans)
    


if __name__ == "__main__":
    import io, sys
    if "_INPUT" in locals():
        sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

while True:
	N = int(input())
	if N>=2 and N<=10**5:break


num = list(map(int, input().split()))
print(num)
ans = reduce(mul,num)
if ans > 10**18:
	print(-1)
else:
	print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def Judge(x,y):
    sum=1
    for i in range(y):
        sum*=x[i]
        #print(sum)
        if sum>10**18:
            return -1
    return sum

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

c=Judge(a,n)
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

# if 0 in list_input:
#     print(0)
#     exit()

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


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

Submission status: Wrong Answer

Solution code:
from math import log10
from decimal import Decimal


def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
    else:
        a_sum = sum(list(map(lambda x: Decimal(log10(x)), a)))
        if a_sum > 18:
            print(-1)
        else:
            print(10 ** a_sum)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import log10
from decimal import Decimal


def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
    else:
        a_sum = sum(list(map(lambda x: Decimal(log10(x)), a)))
        if a_sum > 18:
            print(-1)
        else:
            print(int(pow(10, a_sum)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#d
import math
from collections import deque


n = int(input())
a = []
ans = 0
d = 2
for i in range(2,int(math.sqrt(n)+1)):
    
    if n%i==0:
        a.append(i)
        n/=i
ans = len(a)
if ans == 0 and n >1:
    ans = 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
num=sorted(num)
val = 1

for j in range(0, kaisu):
    if(val/10**18*num[j] < 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
i = 0
b = 1
while i <= n-1:
  b = b * int(a[i])
  i += 1
if b / 10 ** 18 > 1:
  b = -1
print(b)

Submission status: Wrong Answer

Solution code:
#!/bin/python3

import sys
input = sys.stdin.readline

def main():
  n = int(input().strip())
  a = list(map(int, input().strip().split()))
  result = 1
  LIMIT = 10**18
  for i in a:
    result *= i
    if result > LIMIT:
      print(-1)
      sys.exit( )
  print(result)

main()

Submission status: Wrong Answer

Solution code:

from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
number =1


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

print(number)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

main()

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 j in range(0, kaisu):
    if(val/10**18*num[j] < 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
maxi = 10**18
def main():

    mult = 1
    for a in A:
        mult *= a
        if mult > maxi:
            print(-1)
            return 
    print(mult)

main()

Submission status: Wrong Answer

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

def main():
  n = int(input().strip())
  a = list(map(int, input().strip().split()))
  if 0 in a:
    print(0)
    sys.exit()

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

limit = 1000000000000000000

result = 1
for i in A:
  result = result * i
  if result > limit:
    result = -1
    break

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
def main():
    maxi = 10*18
    mult = 1
    for a in A:
        mult *= a
        if mult > maxi:
            print(-1)
            return 
    print(mult)

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
def main():
    maxi = 10*18
    mult = 1
    for a in A:
        mult *= a
        if mult > maxi:
            print("-1")
            return 
    print(mult)

main()

Submission status: Wrong Answer

Solution code:
a = int(input())
b = [int(i) for i in input().split()]

ans =1
b = sorted(b)
for I in b:
  ans = ans*I
  if b[0] == 0:
      print(0)
      break
  elif ans > 10**18:
    print('-1')
    break
if ans != 0 != -1:
    print(ans)

Submission status: Wrong Answer

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

if ans >= 1e18:
  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 j in range(0, kaisu):
    if(val*num[j]/10**18 <= 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

Solution code:
def solve():
  ans = 1
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


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

Submission status: Wrong Answer

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

ans=1
c=0

while c<N:
    ans=ans*A[c]
    c+=1
    
if ans>10000000000000000: 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 j in range(0, kaisu):
    if(val*num[j]/10**18 < 1):
      val = val * num[j]
    else:
      print('-1')
      sys.exit()

print(val)

Submission status: Wrong Answer

Solution code:
import sys

nums = input().split()
ans = 1
for num in nums:
    ans = ans * int(num)
    if ans == 0:
        sys.exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
if 0 in A:
  print(0)
  exit()
ans = 1
for i in A:
  if ans > 10**18 / i:
    print(-1)
    exit()
  else:
    ans *= i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(number)

Submission status: Wrong Answer

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

if c==0:
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
n = int(input())

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

ans = 1 * reduce(mul, alis)
 
if ans < 10**18:
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        print(0)
        return
        
    ans = 1
    for i in range(N):
        ans *= A[0]
        if ans > 1000000000000000000:
            print(-1)
            return
    
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > cnt :
        print(-1)

print(ans)

Submission status: Wrong Answer

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

if 0 in a:
  print(0)
  
for A in a:
  count *= A
  if count > 10**18:
    print(-1)
    exit()
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 1

for a in alis:
  ans *= a
 
if ans < 10**18:
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

N = int(input())
A = [int(a) for a in input().split()]
# print(A)

if 0 in A:
    print(0)
#     print("AA")
else:
    ans = np.prod(A)
    if ans>10**18:
        print(-1)
        sys.exit()
    else:
#         print(type(int(np.prod(A))))
        print(ans)

Submission status: Wrong Answer

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

limit = 1000000000000000000

result = 1
for i in A:
  if result > limit:
    result = -1
    break
  result *= i

print(result)

Submission status: Wrong Answer

Solution code:
#A,B,C=(int(x) for x in input().split())
N=int(input())
A=list(map(int, input().split()))

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def solve():
  n=int(input())
  a=list(map(int,input().split()))
  if 0 in a:
    print(0)
  f=1  
  for i in a:
    f*=i
    if f>100000000000000000:
      print(-1)
      return 
  print(f)
solve()

Submission status: Wrong Answer

Solution code:
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = map(int, input().split())
nums = list(map(int, input().split()))

if "0" in nums:
        print("0")
for num in nums:
    ans *= num
    if ans > cnt :
        print(-1)

print(ans)

Submission status: Wrong Answer

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

print(m)

Submission status: Wrong Answer

Solution code:
def funct(a):
  c = 1
  for i in range(len(a)):
    c *= a[i]
    if(c > 10 ** 18):
      return -1
  return c
n = input()
a = [int(x) for x in input().split()]
print(funct(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

limit = 10E18

result = 1
for i in A:
  if result > limit:
    result = -1
    break
  result *= i

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = [int(i) for i in input().split()]

ans =1
for I in b:
  ans = ans*I
  if ans > 10**18:
    print('-1')
    break
  else:
    if I == b[-1]:
        print(ans)

Submission status: Wrong Answer

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

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 0 < ans <=10**18:
    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(n):
  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()))
count = 1
 
for A in a:
  count = count * A
  if count > 10**18:
    print(-1)
    exit()
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
b=a.replace(' ', '*')
try:
	c=eval(b)
except:
	c = -1
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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





if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

N = int(input())
A = np.array([int(a) for a in input().split()])

if 0 in A:
    print(0)
#     print("AA")
else:
    if np.prod(A)>10**18:
        print(-1)
        sys.exit()
    else:
#         print(type(int(np.prod(A))))
        print(int(np.prod(A)))

Submission status: Wrong Answer

Solution code:
_ = input()
inputs = list(map(lambda x: int(x), input().split()))

value = inputs

n = 0
for input in inputs:
    if n == 0:
        value = input
        continue
value = value * input
n += 1

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

Submission status: Wrong Answer

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

print(m)

Submission status: Wrong Answer

Solution code:
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = map(int, input().split())
nums = list(map(int, input().split()))

if "0" in N:
        print("0")
for num in nums:
    ans *= num
    if ans > cnt :
        print(-1)

print(ans)

Submission status: Wrong Answer

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

  print(m)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = [int(i) for i in input().split()]

ans =1
for I in b:
  ans = ans*I
  if ans > 10**18:
    print('-1')
    break
  else:
    continue
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

N = int(input())
A = np.array([int(a) for a in input().split()])

if 0 in A:
    print(0)
#     print("AA")
else:
    if np.prod(A)>10**18:
        print(-1)
        sys.exit()
    else:
#         print(type(int(np.prod(A))))
        print(np.prod(A))