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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(map(int,input().split()))
ans=1
flag=False
for i in L:
  ans=ans*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()))
res = 1
for i in range(n):
	res *= a[i]
	if res >= 1e18:
		print(-1)
		exit(0)
print(res)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A=lmis()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)





main()

Submission status: Wrong Answer

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

prod = 1
flag = 0
lim = 1e18
for num in A:
  prod = num*prod
  if prod > lim:
    flag = 1
    break
if flag == 1:
  print(-1)
else:
  print(prod)

Submission status: Wrong Answer

Solution code:
input()
ans = 1
for i in map(int, input().split()):
  ans *= i

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
A=[int(b) for b in a]
answer=1
for a in A:
    answer*=a
    if answer>pow(10,18):
        answer=-1
        break
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
c=1
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        print(-1)
        d=1
        break
if(d==0):
    print(c)

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

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

Submission status: Wrong Answer

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

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 sys

def main():
    N=int(input())
    A=list(map(int,input().split()))
    res=1
    for a in A:
        res=res*a
        if res>pow(10,18):
            print("-1")
            sys.exit()
    print(res)
        
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 1

for num in nums:
    sum *= num
    if sum > 1e18:
        print(-1)
        exit()

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A = list(map(int, input().split()))
ans=1
for i in A:
  ans*=i
print(ans)

Submission status: Wrong Answer

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

ans=1
flg=True

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys 
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int,input().split()))
ans = 1
ok = True
for i in range(n):
    if ans>10**18:
        ok = False
        break  
    ans*=a[i]
if ans>10**18:
    ok = False
if ok:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
INF = 10 ** 18


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

    if 0 in A:
        ans = -1
    else:
        ans = 1
        for a in A:
            ans *= a
            if ans > INF:
                ans = -1
                break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = 1
for i in a:
    ans *= i
    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()))
count = 1
for i in a:
    count *= i
print(count)

Submission status: Wrong Answer

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

if A.count(0) <= 1:
    print(0)
    exit(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()

ls = list(map(int,input().split()))
inf = 10**18
ans = 1
for a in ls:
  ans *= a
  if ans >inf:
    ans = -1 
    break
  elif ans == 0:
    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)
        exit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
List = [int(i) for i in input().split()]
total = 1
for i in range(n):
  total *= List[i]
  
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

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

if answer < 1000000000000000000:
    print(answer)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

rl = sys.stdin.readline

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache



def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)



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










if __name__ == "__main__":

    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
flag=False
for a in A:
  ans *= a
  if ans > 1e18:
    flag=True
    break
if flag:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

"""

"""

tot = 1
n = int(input())
done = False
arr = map(int, input().split())

for v in arr:
    tot *= v
    if tot > 10**18:
        print(-1)
        done = True
        break

if not done:
    print(tot)

Submission status: Wrong Answer

Solution code:

import functools
import operator

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

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

Submission status: Wrong Answer

Solution code:
import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
for i in range(n):
	p*=l[i]
	if p>M:
		print(-1)
		f=1
		break
if f==0:
	print(p)

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 = 0

print(ans if ans != 0 else -1)

Submission status: Wrong Answer

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

ans = 1
for i in range(n):
    ans = ans * a[i]
    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()))

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
A =  list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit
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)

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()))
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:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    check = True
    suma = 1
    for i in l:
        suma = suma*i
        if suma>1000000000000000000:
            check = False
            break
    if check:
        print(suma)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

m = 10 ** 18

ans = 1

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(S, 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:

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num = 1

for i in num_list:
  num *= i

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

print(num)

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

Submission status: Wrong Answer

Solution code:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

    inf = 10**18
    res = a[0]
    for i in range(1,n):
        res *= a[i]
        if res > inf:
            print(-1)
            return 0

    print(res)

if __name__ == '__main__':
    main()

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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()
b=1
for i in range(n):
    b*=a[i]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

As = map(int, input().split())
t = 1
for A in As:
    t *= A
    if t > 10 ** 18:
        t = -1
        break

print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
for a in A:
  ret *= a
  
print(min(MAX,ret))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int( input())

A = list( map( int, input().split() ))
sums = np.prod(A)

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

Submission status: Wrong Answer

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

answer=1
for a in alist:
  answer*=a
  if answer>10**18:
    print(-1)
    break
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = [int(x) for x in 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:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

n = int(ipt())
a = [int(i) for i in ipt().split()]
ans = 1
for i in a:
    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
for i in range(N):
  ans = ans * A[i]
  if ans >= 10 ** 18:
    print("-1")
    quit()
  
if ans >= 10 ** 18:
  print("-1")
  quit()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()

    print(cur)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


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

Submission status: Wrong Answer

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