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

N=int(input())

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

result=reduce(mul,A)

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
m=1
for i in a:
  m*=i
print(m if m <= 10**18 else -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 > 1000000000000000000 :
  print("-1")
else :
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
import  functools
import operator
prod=functools.partial(functools.reduce, operator.mul)

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

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:
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 = [int(i) for i in input().split()]

ans = 1
for i in A_list:
    ans *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

t = 1

for i in range(n):
    t = t * a[i]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
up = 10**18
l = list(map(int, input().split()))

ans = 1
for i in l:
    ans *= i
    if i == 0:
        ans = 0
        break
    
if ans > up:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

for k in range (0, n):
  times = times * li[k]

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    lst = list(map(int, input().split()))
    ans = 1
    for i in range(N):
        if lst[i] == 0:
            print(0)
            return 0
        ans *= lst[i]

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Ans=1

for a in A:
    Ans=Ans*a

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

Submission status: Time Limit Exceeded

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

input = sys.stdin.readline


def S():
    return input().rstrip()


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


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


n = I()
al = list(MI())

ans = 1
for i in al:
    ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = [0] * n

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

sum = 1

for i in a:
    sum *= i

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

Submission status: Time Limit Exceeded

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

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

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:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    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(-1 if ans < 0 else ans)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Time Limit Exceeded

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

x = 1
for i in a:
    x *= i
    
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

a = int(stdin.readline())
A=stdin.readline().split()

product=1
for b in range(0,a):
    product=product*int(A[b])
    if product==0:
        break

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



print(product)

Submission status: Time Limit Exceeded

Solution code:
#B
n = int(input())
a = list(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
for i in range(n):
    cnt = cnt*a[i]
if cnt > MAX:
    flg = False
        

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
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:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    for a in A:
        ans *= a
    if ans > 1000000000000000000:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
a = LIST()
res  = 1
for i in range(n):
    res *= a[i]
if res > 10**18:
    print(-1)
    sys.exit()
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Nums = list()
nums = input().split()
for num in nums:
  Nums.append(int(num))
res = 1
for n in range(N):
  if(res*Nums[n]>1000000000000000000): 
    res = -1
  else:
    res*=Nums[n]
print(res)

Submission status: Time Limit Exceeded

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

t = 1

for i in range(n):
    t = t*a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:


def submit():
    n = int(input())
    a = (int(e) for e in input().split())
    thr = 10 ** 18

    ans = 1
    for e in a:
        ans *= e
    
    if ans > thr:
        print(-1)
    else:
        print(ans)


submit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if ans <= tmp:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
m = 1000000000000000000

n = input()
a = [int(i) for i in input().split()]

o = 1

for i in a:
    o = o * i
if o > m:
    o = -1

print(o)

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = 1
for Ai in input().strip().split(' '):
    a *= int(Ai)
if a > 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 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()))
 
res = 1
 
for i in a:
  res *= i
 
if res > 1000000000000000000:
  print(-1)
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    A = kwargs["A"]
    res = 1

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

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

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Time Limit Exceeded

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

N=int(input().rstrip('\n'))
As =[int(x) for x in input().rstrip('\n').split()]
res = 1
for i in range(N):
  res =res*As[i]
if res > 10**18:
  res = -1
print(res)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
ans = 1

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8
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:
# -*- coding: utf-8 -*-
import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD
combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''
"#a,bの最大公約数"
def gcd(a, b):
    while b:#0以外なら進んでいくが、0になった時にとまる余りが0より、最大公約数と言える
        #print(a,b)#2,3
        #やり方てきにユークリッドの互除法か
        a, b = b, a % b#aには2 bには2%3が入る
    return a

"#a,bの最小公倍数"
def lcm(a, b):
    return a * b // gcd (a, b)

"#nの約数を全て求める"
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')
# abc---xyz

print('abc', end='')
print('xyz')
# abcxyz
source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    #lenを変数に置くと事故るから注意
    n=int(input())
    #a,b=input().split(#" ")#a,bがともに文字列のとき
    #a,b=map(int, input().split(" "))
    #mapでとってもstrで変換すればappend可能
    #s=input()
    #a=[i for i in s]#int(i)にすれば数字も行ける
    nl=list(map(int, input().split(" ")))#数字の時
    #print(a)
    #brray=[list(map(int, input().split(" ")))for i in range(n)]
    #print(brray)
    n=len(nl)
    ans=1
    for i in range(n):
        ans=ans*nl[i]
    if ans>10**(18):
        print(-1)
        sys.exit()
    print(ans)
    #for i in range(1,n+1,2):#これで1個飛ばしループになる
    # pass
     #print(i)

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')#ある要素のインデックス番号を取得
    #s = ''.join(l)
    #s = " ".join(map(str,a))#スペースを空ける時はこう
    #print(s)
    # aaabbbccc

    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

x = 1
for i in range(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 = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

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

for a in map(int, input().split()):
    ans *= a

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

Submission status: Time Limit Exceeded

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

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

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

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



if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

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


def main():
    limit = 10**18
    N = int(input())
    A = list(map(int, input().split()))
    assert N == len(A)
    answer = 1
    for i in A:
        answer *= i
    print(answer) if answer <= limit else print("-1")


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 a:
  ans *= i
if not ans > (10 ** 18):
  print(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

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

ans =A[0]

for i in A[1:]:

    ans = ans * i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
t = 10**18

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

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

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

Submission status: Time Limit Exceeded

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

answer = 1
for i in range(n):
    answer*=a[i]
    
if answer>int(1e+18):
    print(-1)
else:
    print(answer)

Submission status: Time Limit Exceeded

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

    for a in A:
        cnt *= a 
    if cnt > 1e18:
        print(-1)
    else:
        print(cnt)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


t=sorted(s)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18

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

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

result = 1
for i in range(N):
    result *= NList[i]

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

Submission status: Time Limit Exceeded

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