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

ar = [0 for _ in range(n)]

ar = [int(s) for s in input().split()]

res = 1

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

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

Submission status: Time Limit Exceeded

Solution code:

ans = 1
n = int(input())
arr = list(map(int , input().split()))
for i in range(n):
	ans*=arr[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()))
mod=10**18

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

if cnt>mod:
    print(-1)
else:
    print(cnt)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

pro = 1

for i in a:
    pro = pro * i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
AA = list(map(int,input().split()))
res = AA[0]
for a in AA[1:]:
    res = res*a
if res>1e18:
  print('-1')
else:         
  print(res)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    # print(ans)
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

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:
import numpy as np;




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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

maxn = 10**18
ans = 1
for k in a:
    ans *= k

if ans > maxn:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**20
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
a = rl()
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())
As = list(map(int, input().split()))
ans = 1
for a in As:
    ans *= a
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    n = int(input())
    a = list(map(int, input().split()))
    # l = [list(map(int, input().split())) for _ in range(n)]

    thr = 10 ** 18
    ans = 1

    for a_i in a:
        ans *= a_i

    if ans > thr:
        ans = -1

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1000000000 1000000000"""
        output = """1000000000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
101 9901 999999000001"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """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"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Time Limit Exceeded

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

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

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

max = 10 ** 18
result = 1
for i in A:
    result = result * i

if result > max:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
n = input()

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

MAX = 10**18

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

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in list:
    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 a in A:
  ans *= a

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

Submission status: Time Limit Exceeded

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Submission status: Time Limit Exceeded

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

    ans = 1
    for i in range(n):
        ans *= As[i]
        if ans == 0:
            break

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:01:36 2020

@author: 81807
"""


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

Submission status: Time Limit Exceeded

Solution code:

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

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 x in a:
    ans*=x

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())
a = list(map(int,input().split()))
num = 1
for x in a[:]:
    num*=x
    if num == 0:
        break
if 10**18<num:
    num = -1
print(num)

Submission status: Time Limit Exceeded

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

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 == 0):
        break
if(p > 10**18):
    print(-1)
else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

    print(A)

Submission status: Time Limit Exceeded

Solution code:
from __future__ import division, print_function

''' Hey stalker :) '''
INF = 10 ** 10
TEST_CASES = False
from collections import defaultdict, Counter

def main():
    n = get_int()
    li = get_list()
    res = 1
    k = 0 in li
    for i in li:
        res*=i
        #print(res)
        if res>10**18 and not k:
            print(-1)
            return
    print(res)

''' FastIO Footer: PyRival Library, Thanks @c1729 and contributors '''
import os
import sys
from bisect import bisect_left, bisect_right
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
# else:
#     sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
if __name__ == "__main__":
    if TEST_CASES:
        [main() for _ in range(int(input()))]
    else:
        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 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
LIMIT=10**18
for i in range(n):
  ans*=A[i]
if ans>LIMIT:
  ans=-1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

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

Submission status: Time Limit Exceeded

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

s = 1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())
#n,m=input_list()
a=input_list()
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 range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

S=1

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = 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())
ss=[a for a in input().split()]

res=1
for i in ss:
    res=res*int(i)
    
    if res>10**18:
        res=-1
print(res)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
ans = reduce(mul, A)
print(ans if ans <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

result = reduce(mul, a_list)

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

Submission status: Time Limit Exceeded

Solution code:
x  = int(input())

line  = [int(y) for y in input().split()]

yeet  = 1

for i in range(0,x):
    yeet = yeet*line[i]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

k = 1

for i in l:
    k = k*i

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[0]*n
a=list(map(int,input().split()))

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

if (ans>=0):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
res = 1
for i in range(n):
    res *= arr[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()))

tmp = 1
import sys

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from pprint import pprint
import sys
sys.setrecursionlimit(10**7) 

N = int(input())
An = [int(_) for _ in input().split()]

ans = 1;
for i in An:
    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 = 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= map(int,input().split())
 
ans = 1
for i in a:
    ans *= i
if(ans > 1e18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
ans = A[0]
for i in range(1, len(A)):
    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:
from functools import reduce
from operator import mul
n = int(input())
A = map(int, input().split())
ans = reduce(mul, A)
print(ans if ans <= 10**18 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in range(n):
  final*=lis[i]
if final>10**18:
  print("-1")
else:
  print(final)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for x in A:
    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()))

total = a[0]
for i in range(1,N):
    total *= a[i]
if  10 ** 18 < total:
    print(-1)
else:
    print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

for x in A:
        ans *= x
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):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# B
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(a) for a in input().split()]
ans=1
for i in range(len(A)):
    ans=ans*A[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()))
c = 1
for i in a:
    c *= i
if c > (10 ** 18):
    print(-1)
else:
    print(c)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A_list[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = int(reduce(mul, a))
    if r > largenum:
        r = -1
    print(r)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
num=int(input())
date0=input().rstrip().split(" ")
sum=1
for i in range(num):
    sum=sum*int(date0[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 = int(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:
def readInt():
    return list(map(int, input().split()))

ans = 1
n = int(input())
a = readInt()
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 = [int(x) for x 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(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
INF = 10 ** 18
for n in a:
    ans *= n

if ans > INF:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
ans=1
for x in a: ans*=x
if ans>1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in A:
    sum *= 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()))

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

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