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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
L = list(map(int,input().split()))
a = 0
for i in L:
    a += len(str(i))-1



#print(a)
if a > 18:
    print(-1)
else:
    b = 1
    for i in L:
        b = b*i
    if b <= 10**18:
        print(b)
    else:
        print(-1)

Submission status: Wrong Answer

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

ans = 1

for l in line:
    ans = int(l) * ans

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n = int(input())

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

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

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

import functools
import operator

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
An_all = input().split()
An = []
for i in range(N):
    An.append(int(An_all[i]))

mult = 1
for i in range(N):
    mult = mult * An[i]

if mult >= 10e18:
    print(-1)
else:
    print(mult)

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    n = int(stdin.readline().rstrip())
    #A, B = map(float, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for i in range(n):
        if ans > 10**18:
            print(-1)
            exit()
        ans *= A[i]
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
#整数の入力
N = int(input())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

if((0 in A_list) ==True):
  print("0")
  exit()
  
ans = 1
for i in range(N):
  if(ans<10**18):
    ans = ans * A_list[i]
  else:
    print("-1")
    exit()
    
if(ans<10**18):
    print(ans)
else:
  print("-1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

print(answer)

Submission status: Wrong Answer

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

limit = 10 ** 18

sum = 1
for i in range(N):
    if (AB[i] == 0):
        print(0)
        exit()
    sum *= AB[i]
    if (limit < sum):
        print(-1)
        exit()

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

maxval = 10 ** 18
ans = 1

for i in a:
    if ans <= maxval:
        ans *= i
    else:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=input()
a0=a.split()
l=list()
b=1
for i in range (n):
    a1=int(a0[i])
    b=b*a1
    if b>10**18:
        print(-1)
        sys.exit()
print(b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in 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:
import sys
a=int(input())
b=list(map(int,input().split()))

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

Submission status: Wrong Answer

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

def product_many(N):
    if 0 in N: return 0
    ans = 1
    for x in N:
        ans *= x
        if ans > 10 ^ 18: return -1
    return ans

def main():
    _ = input()
    N = list(map(int, input().split()))
    print(product_many(N))

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul

N=int(input())

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

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

Submission status: Wrong Answer

Solution code:
import math
ans = 1
n = int(input())
A = [int(i) for i in input().split()]

for i in A:
    ans *= i
if ans ==0:
    print(0)
    exit()
if math.log10(ans)>18:
    print('-1')
    exit()
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

A.sort(reverse=True)
print(A)
result = A[0]
for a in A[1:]:
    if result * a > 10**18:
        print(-1)
        exit()
    else:
        result = result * a

print(result)

Submission status: Wrong Answer

Solution code:
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
i = 0
ais.sort(key = lambda x:-x)
if ais[-1] == 0:
	cumul = 0
while(i < len(ais) and cumul < 10 ** 18):
  cumul *= ais[i]
  i +=1
  if cumul == 0:
  	break

print cumul if cumul > 10 ** 18 else -1

Submission status: Wrong Answer

Solution code:
n=int(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:
N = int(input())
A = 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())
arr = list(map(int,input().split()))
arr = sorted(arr,reverse=True)
ans = 1
idx = 0
for a in arr:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 20:04:25 2020

@author: k
"""

n = int(input())
a = input().split()
inf = 1000000000000000000
ans = 1
for x in a:
    x = int(x)
    ans = ans*x
    if ans > inf:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 1
for i in lis:
    ans *= 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
printed = False
for x in a:
    ans *= x
    if ans > 1e18:
        print(-1)
        printed = True
        break
        
        
    
if not printed:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
  print(0)
  exit()
for i in a:
    s*=i
    if  s >= 10**18:
        print(-1)
        exit()
print(s)

Submission status: Wrong Answer

Solution code:
s = input()
s = s.split()
ans = 1
for i in s:
  ans *= int(i)
if ans > 1000000000000000000:
  print(-1)
else:
 	print(ans)

Submission status: Wrong Answer

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

ans = 1
for t in a:
	ans *= t
	if ans > 1e18:
		print(-1)
		exit(0)

print(ans)

Submission status: Wrong Answer

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

ans = 1
burst = False
for k in K:
    ans *= k
    if ans > 10**18:
        burst = True
        break

print(-1) if burst else print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N=int(input())
A=list(map(int, input().split()))
a=A[0]
for i in range(1,len(A)):
  a*=A[i]
  if pow(10,18)<a:
    print('-1')
    exit(0)
print(a)

Submission status: Wrong Answer

Solution code:
int(input())
numbers = tuple(map(int, input().split(' ')))

mul = 1
for n in numbers:
    mul *= n
    if mul == 0:
        print(0)
        break
    elif mul > 10 ** 18:
        print(-1)
        break
else:
    print(mul)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
data = input().split()
val = 1
for i in data:
  val = val * int(i)
  # print(val)
  # if val > 10**18:
  #   break

if val > 100000000:
  print(-1)
else:
  print(val)

Submission status: Wrong Answer

Solution code:
import sys
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = a[0]
    for i1 in range(1, n):
        if r > largenum:
            print(-1)
            sys.exit()
        else:
            r *= a[i1]
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 1
ma = 1e18

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

Submission status: Wrong Answer

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

s = 1
mod = pow(10, 18)
for i in a:
    s = s*i
    if s < mod:
        print(-1)
        exit()
else:
    print(s)

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 // 1000000000000000000 > 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
c=np.array(A)
p=np.prod(c)
if p>10**18:
    print(-1)
else:
    print(p)

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

ans = 1

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

Submission status: Wrong Answer

Solution code:
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
mul=1
flag=0
for i in range(n):
    mul=mul*a[i] 
    if mul>1000000000000000000:
        flag=1 
        break
if flag==0:
    print(mul)
else:
    print(-1)

Submission status: Wrong Answer

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

for i in range(len(a)):
    print(a[i])
    if a[i] == 0:
        print(0)
        exit()

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

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

print(ans)

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:
N = int(input())
A = map(int,input().split())
ans =1
if min(A) == 0:
    print(0)
    exit()
for a in A:
    ans *= a
    if ans > 1e18:
        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 range(0,n):
  ans*=A[i]
  if ans>10**18:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
def main ():
  input()
  result = 1
  for i in map(int, input().split()):
    result = result * i
    if result > 10 ** 18:
      result = -1
      break
    if result == 0:
      break
  
  return result

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
l = [int(e) for e in input().split(" ")]
res = 1
for e in l:
    res = res*e
if res > 10e18:
    print("-1")
else:
    print(res)

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 = input()
A = map(int, input().split())
val = 1
for a in A:
    val *= a
    if val > 10 ** 18:
        print(-1)
        exit()
print(val)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
import sys
import numpy as np
input = sys.stdin.readline
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:
n = int(input())
li = list(map(int, input().split()))

ans = 1
flag = 0
for i in li:
  ans *= i

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = 1
for i in y:
  res *= i
  if res > int(1e+18):
    print(-1)
    exit(0)
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
total = 1
for i in range(N):
    total *= A[i]
    if 10**18 < total:
        break

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

Submission status: Wrong Answer

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

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())
 
l = list(map(int,input().split()))
 
ans = 1
 
for i in l:
    ans *= 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
a.sort()

for i in a:
    if i == 0:
        ans = 0
        break
    elif ans > 10**18:
        ans = -1
        break
    else:
        ans = ans * i

print(ans)

Submission status: Wrong Answer

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

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

total = 1
for i in range(N):
    total = total*A_list[i]
    if total // 10**18 >= 1:
        print(-1)
        exit()

print(total)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import numpy as np

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

mult = np.prod(a)

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

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 > 1000000000000000000 :
    print("-1")
    sys.exit()

print(ans)

Submission status: Wrong Answer

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

ans = 1
above = False
for x in a:
	ans *= x
	if ans > 10**18:
		above = True
		break

if not above:
	print(ans)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
input()
l = list(map(int,input().split()))
s = 1
for i in l:
  s*=i
print(s if s<=10e+18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list( map( int , input().split() ))
prod =1
 
for i in a :
  if  i * prod > 1e18:
    print(-1)
    exit(0)
  else:
    prod *= i
 
print(prod)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

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

total = np.prod(A)
if total > 10 ** 18:
    print(-1)
else:
    print(total)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

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

    print(ans)



if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

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

print(r)

Submission status: Wrong Answer

Solution code:
n=int(input())
alis=list(map(int,input().split()))
p=alis[0]
inf=10e+18
for i in range(1,n):
  p*=alis[i]
  if len(str(p))>18:
    print(-1)
    exit()
print(p)

Submission status: Wrong Answer

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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:
        print("-1")
        break
else:
    print(Ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l = list(map(int,input().split()))
s=1
if 0 in l:
    print(0)
else:
    for i in l:
        s*=i
        print(s)
        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()))

ans = int(np.prod(a))
if ans > 10**18:
  print('-1')
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = np.prod(A)
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

border_num = 10 ** 18


if 0 in nums:
    output = 0
else :
    output = 1
    for _ in nums :
        output *= _
        if output >= border_num:
            output = -1
            break
            
print(output)

Submission status: Wrong Answer

Solution code:


def solve(N, As):
    ans = 1
    for a in As:
        ans *= a
        if ans > 10 ** 18:
            return -1
    return ans


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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