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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
apple = list(map(int, input().split()))
cat = 1
for i in apple:
    cat *= i
print(cat if cat <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
l = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
s = 1
for i in l:
    s *= i
if s > 10**18:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, *a = map(int, open(0).read().split())

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_ls = list(map(int, input().split()))
mul = 1

for i in range(N):
  mul *= A_ls[i]

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input(''))
s=input('')
s=s.split(' ')
p=1
f=0
for a in range(n):
    s[a]=int(s[a])
    p=p*s[a]

if p>10**18:
    f=1

if f==1:
    print(-1)
else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
import functools

def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]

    ret = functools.reduce(lambda x, y: x*y, A)
    if ret > 1e18:
        print('-1')
    else:
        print(f'{ret}')


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import deque
from collections import defaultdict

import time

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
a = readInts()

ans = 1

d = defaultdict(int)

for i in a:
	d[i]+=1

for k in d:
	ans*=k**d[k]

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
from queue import PriorityQueue
import itertools
from copy import deepcopy
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):
    if b:print("yes")
    else:print("no")
def Yn(b):
    if b:print("Yes")
    else:print("No")
def YN(b):
    if b:print("YES")
    else:print("NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(bbool,ret1,ret2):
    if bbool:return ret1
    else:return  ret2
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def pm(x):
    return x//abs(x)
def inputintlist(): 
    return list(map(int,input().split()))
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def ruisekiwa(A):
    ret=[0]*(len(A)+1)
    for a in range(len(A)):
        ret[a+1]=ret[a]+A[a]
    return ret
def getmd(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow









######################################################################################################
n=int(input())
A=inputintlist()
ans=1
for a in A:
    ans*=a
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

    if ans > limit:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

res = 1
thr = 10**18
for a in A:
    res *= a

if res > thr:
    res = -1

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

x=a[0]
for i in range(1,n):
    x=x*a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
t=int(input())
s=list(map(int,input().split()))
n=1
for i in s:
   n*=i
if n>1000000000000000000:
    print("-1")
else :
    print(n)

Submission status: Time Limit Exceeded

Solution code:
n = input()
a = list(map(int, input().split()))
sum = 1
for i in a:
  sum *= i

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in a:
    ans *= i

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

for x in A:
    ans = ans * x

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n=int(input())

l=list(map(int,input().split()))
a=1
for i in range(0,n):
	a=a*l[i]


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


if a<10**18+1:
	print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans = ans * i 
	if ans > mod:
		print(-1)
	else:
		print(ans)

Submission status: Time Limit Exceeded

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

sum_num = 1
for t in input_list:
    sum_num *= t


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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

result = 1

for x in a:
    result *= x

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    res = 1

    for item in A_list:
        res *= item

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

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

ans = 1
for x in arr:
    ans *= x
    
if ans > int(1e18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
for i in x:
    prod *= i
    if prod == 0:
        print(0)
        exit()
if prod > ele:
    print(-1)
    exit()
print(prod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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
	
if f==0:
	print(p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))
ans = li[0]
for i,l in enumerate(li):
    if i == 0:
        continue
    else:
        #print(l,'l')
        ans *= l
        #print(ans)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if 0 in alist:
    print("0")
else:
    result=1
    for a in alist:
        result*= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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

ans = a[0]
for i in range(1, n):
  ans = ans * a[i]

if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for n in range(1,N):
  ans = ans * A[n]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N = I()
A = LI()
 
i = 10**18
ans = 1
if 0 in set(A):
    print(0)
else:
    for a in A:
        ans *= a
    if ans > i:
        print(-1)
    else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:

a=int(input())
b=list(map(int, input().split()))
c=1
d=0
if 0 in b:
    d=1
for i in range(a):
    c*=b[i]
    if d!=1 and c>10**18:
        print(-1)
        exit()


print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
upper = 1e18
res = 1
for x in map(int, input().split()):
   res *= x
print(-1 if res > upper else res)

Submission status: Time Limit Exceeded

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
  
if ans==0:
  flag=0
if flag==0:
  print(ans)
else:
  print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a=[int(i) for i in input().split()]
for i in a:
    z*=i

if(z>mx)    : z=-1
print(z)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
A = tuple(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
for k in d:
    ans *= k**d[k]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import operator

input()
ans = reduce(operator.mul, map(int, input().split()), 1)
ans = ans if ans <= 10 ** 18 else -1
print(ans)

Submission status: Time Limit Exceeded

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

a0 = a[0]
a_else = a[1:]

for ai  in a_else:
    a0 *= ai


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [] * n

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: Time Limit Exceeded

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

for i in a:
  ans*=int(i)
  
if ans>10**18:
  print("-1")
else:
  print(str(ans))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mylist = map(int,input().split())
myans = 1
for m in mylist:
    myans *= m
if myans <= 10**18:
    print(myans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
MAX_NUM = 10 ** 18

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

    print(ans)



main()

Submission status: Time Limit Exceeded

Solution code:

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

x = functools.partial(functools.reduce, operator.mul)
ans = x(a)
if ans > 10 ** 18:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
s = functools.reduce(operator.mul, a)
if(s > 1e18):
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def default():
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    for i in range(0,n):
        temp[i]=int(temp[i])
        answer*=temp[i]
    if(answer>1000000000000000000):
        print(-1)
    else:
        print(answer)

if(__name__=="__main__"):
    default()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1
for i in A:
  res *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    _ = int(input())
    x = 1
    for a in map(int, input().split()):
        x *= a
    if x > 10 ** 18:
        print(-1)
    else:
        print(x)

if __name__ == '__main__':
    main()