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:
from operator import mul
from functools import reduce
n, *A = map(int, open(0).read().split())
m = reduce(mul, A)
if m > 10**18:
    print(-1)
else:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

a = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = a[0]
for i in a[1:]:
    m *= i

if m > pow(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 > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
#import math
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

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=list(map(int,input().split()))
ans=a[0]
i=1
while i<n:
    ans*=a[i]
    i+=1
if ans>1000000000000000000:
    ans=-1
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
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())
numList = list(map(int, input().split()))
product = 1
for i in numList:
    product *= i
if product > 10**18:
    print(-1)
else:
    print(product)

Submission status: Time Limit Exceeded

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

if 0 in a_lst:
    print(0)
    quit()
else:
    res = a_lst[0]
    for a in a_lst[1:]:
        res *= a
    if res > 10 ** 18:
        print(-1)
    else:
        print(res)

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

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

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

goukei = 1
for i in ls:
  goukei *= i

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

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
A =  [int(i) for i in input().split()]
ans = 1

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

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

Submission status: Time Limit Exceeded

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

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, 1):
    ans = ans * a[i]
if ans > 1e+18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase
# def gcd(a,b):
#     if b==0:

#         return a
#     else:
#         return gcd(b,a%b)
def main():
    # mod=10**9+7
    #for _ in range(int(input())):
    n=int(input())
    arr=[int(k) for k in input().split()]
    res=1
    for i in range(n):
        res*=arr[i]
    if res>10**18:
        print(-1)
    else:
        print(res)







BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()

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

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

if s > 1e18:
    print("-1")
else:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()
a = RI()

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

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:
from functools import reduce
from operator import mul

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n =ni()
    s = na()
    l = pow(10,18)
    ans = 1
    for i in s:
        ans *= i
    if ans > l:
        print(-1)
        return
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
A1 = 1
for i in A:
    A1 *= i
if A1 > 1*10**18:
    print("-1")
else:
    print(A1)
#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')

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:
def product(list):
    i=1
    for j in list:
        i*=j
    return i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = 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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


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


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))

    ans = 1

    for i in a_list:
        ans *= i

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


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
m = input()
l = list(map(int, input().split()))
ans = 1
tmp = pow(10, 18)
for i in l:
    ans *= i

if ans <= tmp:
    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 a:
    ans = ans * i


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
import math
from collections import Counter
import itertools
import fractions
#import numpy as np
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
n=II()
A=LI()

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8
from operator import mul
from functools import reduce

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import math
import sys

input = sys.stdin.readline
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)
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 *= 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 = 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()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

limit = 10 ** 18
res = A[0]

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

Submission status: Time Limit Exceeded

Solution code:
#! /usr/bin/env python3
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

a = l()

ans = a[0]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

ans = 1
for i in range(N):
  ans *= a[i]

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

Submission status: Time Limit Exceeded

Solution code:
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
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:
def main():
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    ans = 1
    for a in A_list :
        ans = ans * a
    if ans > 10 ** 18 :
        ans = -1

    print(ans)

if __name__ == '__main__':
    main()

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
A = list(map(int, input().split()))
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]
INF = 10**18
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())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans*=a[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()))
X = 1
if 0 in A:
  print(0)
else:
  flg = True
  for i in range(N):
    X *= A[i]
    if X > int(1e18):
      flg = False
  if flg:
    print(X)
  else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ANS=List[0]
i=1
while i<N:
    ANS=ANS*List[i]
    i+=1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def solve(N: int, A: "List[int]"):
    ans = 1
    for a in A:
        ans = ans * a

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))
    ans = 1
    for d in data:
        ans *= d
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in lis:
    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 = 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:
import sys

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

if 0 in a:
    ans = 0
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import collections
from collections import Counter
def li():
    return list(map(int,input().split()))
n=int(input())
p=li()
s=1
for i in range(n):
    s*=p[i]
if s>=10**18+1:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

answer = 1
for a in A:
    answer *= a

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

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)