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 sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n = int(input())
    ans = 1
    for i in map(int, input().split()):
        ans *= i
    if ans > 1e18:
        print(-1)
    else:
        print(ans)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input());

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

ok = True;
ans = 1;
for val in a:
    ans *= val;

if(ans > 1e18):
    ok = False;
if(ok):
    print(ans);
else:
    print(-1);

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

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


a=sorted(A,reverse=True)

A_product=1
flag_1e18=False

for i in range(0,N,1):
  A_product=A_product*a[i]
  if A_product>1e18:
    flag_1e18=True
  elif A_product==0:
    flag_1e18=False
  else:
    continue
    
if flag_1e18==True:
  print(-1)
else:
  print(A_product)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
a.sort()
# print(a)

result = 1
for x in a:
    result *= int(x)
    if result == 0:
        break

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

Submission status: Time Limit Exceeded

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

result = 1
for x in a:
    result *= int(x)

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n = stdin.readline().rstrip()
a = stdin.readline().rstrip().split()

total = 1
for i in a:
    total = total*int(i)

if(total > 1000000000000000000): total = -1
print(total)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
Π = functools.partial(functools.reduce, operator.mul)

N  = int(input())
A  = [int(x) for x in input().split()]
AM = Π(A)
if AM > pow(10,18):
    print('-1')
else:
    print(str(AM))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n = stdin.readline().rstrip().split()
a = stdin.readline().rstrip().split()

total = 1
for i in a:
    total = total*int(i)

if(total > 1000000000000000000): total = -1
print(total)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n, *a = map(int, open(0).read().split())
ans = reduce(lambda x, y: x * y, a)
print([ans, -1, 0][10**18 < ans + 2*(ans == 0)])

Submission status: Time Limit Exceeded

Solution code:
def solve(string):
    from functools import reduce
    from operator import mul
    n, *a = map(int, string.split())
    a = reduce(mul, a)
    return "-1" if a > 10**18 else str(a)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Time Limit Exceeded

Solution code:
from __future__ import division, print_function

INF = 1e18

def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    
    mul = 1
    for i in a:
        mul = mul * i

    if mul > INF:
        mul = -1;

    print(mul)

# PyPy 2 Fast IO
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

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

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')

# Importing Modules
import math
import collections

from collections import Counter
from math import fabs

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = list(map(int, input().split()))
res = arr[0]
 
for a in arr[1:]:
  res *= a
 
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

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

mx = 10**18

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

print(ans) if ans <= mx else print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nums = list(map(int,input().split(" ")))
s = 1
for num in nums:
    s = s * num
if s > 10**18:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
input()
print(a if (a:=reduce(lambda x,y:int(x)*int(y), input().split()))<=1e18 else -1)

Submission status: Time Limit Exceeded

Solution code:
# B - Multiplication 2
from functools import reduce
from operator import mul


def main():
    _, *A = map(int, open(0).read().split())
    prod = reduce(mul, A)
    print(prod if prod <= 10 ** 18 else -1)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    m = map(int, input().split())
    ans = 1
    for i in m:
        ans *= i
    print(ans) if ans <= 1000000000000000000 else print(-1) 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = input()
A = list(map(int, input().split()))
a = 1
if 0 in A:
  print(0)
else:
  a = reduce(lambda x, y:x*y, A)
  if a > 10**18:
      print(-1)
  else:
    print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date:2nd june 2020
'''

def Solve():
    n=int(input())
    ar=[int(x) for x in input().split()]
    #print(ar)
    ans=1
    for x in ar:
        ans=ans*x
    print("-1" if ans>10**18 else ans)
Solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A=int(input())
B=input().split(" ")
D=1
for C in B:

  if C=="0":
    D=0
    break
  else:
    D=int(D)*int(C)
    continue
if D>10**18:
  D=-1
print(D)

Submission status: Time Limit Exceeded

Solution code:
import math
import re
import copy
import sys

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
d = list(map(int,input().split()))
i = 0
while i < n:
    ans *= d[i]
    i += 1

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

Submission status: Time Limit Exceeded

Solution code:
input()
l = list(map(int, input().split()))
res = 1
for x in l:
  res *= x
if res > 10**18:
  res = -1
print(res)

Submission status: Time Limit Exceeded

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

tot = 1
for x in arr:
    tot *= x

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

product = 1
for num in n_list:
    product = product * num

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

else:
    print(product)

Submission status: Time Limit Exceeded

Solution code:
_ = int(input())
a = [int(i) for i in input().split()]

isOverflow = False

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

print(-1 if mul > 1000000000000000000 else mul)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = list(map(int,input().split()))
Ans = 1
# print(len(L))
for i in L:
    Ans = Ans * i
if (10**18 - Ans) < 0:
     print(-1)
else:
    print(Ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for val in list:
    Point *= val

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

Submission status: Time Limit Exceeded

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

for val in list:
    Point = Point * val

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

Submission status: Time Limit Exceeded

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

for val in list:
    Point = Point * val

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
numbers = list(map(int,input().split()))
sum = 1
for i in range(num):
  sum *=numbers[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()))
x=10**18
ans=1
for num in a:
    ans*=num
    if 0 in a:
        ans=0
        break
    if ans>x:
        ans=-1
        break    
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]
    i += 1
if s > 10**18:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python

import sys
import math 

#Input Functions
#===============

input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

#===============

def run_test() :
    n = inp()
    a = inlt()
    ans = 1
    zero = False
    invalid = False
    for i in a :
        ans *= i
        if i == 0 : zero = True
        if ans > 1000000000000000000 : invalid = True
    if zero : ans = 0
    elif invalid : ans = -1
    print(ans)

def main() :
	run_test()

if __name__ == '__main__' :
	main()

Submission status: Time Limit Exceeded

Solution code:
n,*l=map(int,open(0).read().split())
a=1
for i in sorted(l): a*=i
print([a,-1][a>10**18])

Submission status: Time Limit Exceeded

Solution code:
n,*l=map(int,open(0).read().split())
a=1
for i in l: a*=i
print([a,-1][a>10**18])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a=(input().split())
#print(a)
ans=1

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

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

for i in a:
    cnt *= i
if cnt <= 10 ** 18:
    print(cnt)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
nums = [int(e) for e in input().split()]
# print(nums)

ans = 1

for i in nums:
  ans = ans * i

s = 10**18

if(ans > s):
  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 sorted(a):
    ans = ans*i
    if ans == 0:
        break
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()))

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
p=1
l=input()
num=input().split()
for n in num:
    p*=int(n)
mx=pow(10,18)
if(p>mx):
    print("-1")
else:
    print(p)

Submission status: Time Limit Exceeded

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

ans = num_list[0]
LIMIT_NUM = 10**18
for i in range(1,N):
  ans *= num_list[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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:
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
	ans *= a[i]
if(ans > 1000000000000000000):
	print("-1",end="")
else:
	print(ans,end="")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan
import cmath as cma
import copy as cp
import sys
import re
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()
ans = 1
for num in a: ans *= num
ans = -1 if ans>10**18 else ans
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:


import sys

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

n, *a = map(int, read().split())

val=1
for x in a:
    val*=x

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def multiply2(A):
    res = 1
    for item in A:
        res *= item
    if res > 10**18:
        return '-1'
    else:
        return res

if __name__ == "__main__":
    N = int(input())
    A = []
    A = list(map(int, input().split()))
    print(multiply2(A))

Submission status: Time Limit Exceeded

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

MAX = 10**18
ans = 1

for i in a:
    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()))

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    ans = 0
else:
    for i in a:
        ans *= i

print(ans if ans <= inf else -1)

Submission status: Time Limit Exceeded

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

inf = 10**18
ans = 1

if 0 in a:
    ans = 0
else:
    sorted(a, reverse=True)
    for i in a:
        ans *= i

print(ans if ans <= inf else -1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c=1
f=1
a=list(map(int,input().split()))
for i in range(0,n):
  if a[i]==0:
    f=1
    c=0
    break
  if c*a[i]>1e18 or f==0:
    c*=a[i]
    f=0
    continue
  c*=a[i]
if f==0: print(-1)
else: print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
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:
n = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cumul = 1
for i in range(N):
    cumul *= nums[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = input()
A_str = input().split()

if "0" in A_str:
    print(0)
    exit()

c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
    res *= int(i) ** v

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

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num_list = list()
string = input().split()
for i in range(n):
	num_list.append(int(string[i]))
pro = 1
for number in num_list:
	pro *= number
if pro > 10**18:
	pro = -1
print(pro)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
ls = list(map(int, input().split()))
ans = math.prod(ls)
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()))
if 0 in ls:
    print(0)
else:
    ans = 1
    for i in ls:
        ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
def check():
  n=int(input())
  A=list(map(int,input().split()))
  if 0 in A:
    print(0)
    return
  a=1
  for i in A:
      a=a*i
  if a>1000000000000000000:
    print(-1)
    return
  print(a)
  return


check()

Submission status: Time Limit Exceeded

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

def check(A):
  if 0 in A:
    return 0
  a=1
  for i in A:
      a=a*i
  if a>1000000000000000000:
    return(-1)
  return a

print(check(A))

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
n=int(input())
a=list(map(int,input().split()))
res=1
if 0 in a:
    print(0)
else:
    for i in a:
        res*=i
    if(res>1000000000000000000):
        print(-1)
    else:
        print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = input()
l = list(map(int,input().split()))
if 0 in l:
    print(0)
    sys.exit()
result = 1
for i in l:
    result *= i
if result > 1000000000000000000:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
n=int(input())
a=list(map(int,input().split()))
res=1
if 0 in a:
    print("0")
else:
    for i in a:
        res=res*i
    if(res>1000000000000000000):
        print("-1")
    else:
        print(res)

Submission status: Time Limit Exceeded

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

s = 1


for i in range(len(A_list)):
        s = s*A_list[i]
        if A_list[i] == 0:
            print("0")
            sys.exit()
if s>pow(10,18):
        print("-1")
else:
        print(s)

Submission status: Time Limit Exceeded

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

s = 1
if A_list[0] == 0:
    print("0")
else :
    for i in range(len(A_list)):
        s = s*A_list[i]
    if s>pow(10,18):
        print("-1")
    else:
        print(s)

Submission status: Time Limit Exceeded

Solution code:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

if __name__ == '__main__':
	n=int(stdin.readline())
	l=list(map(int,stdin.readline().split(" ")))
	c0=0
	p=1
	for i in range(n):
		p=p*l[i]
		if(p==0):
			break
	if(p>1000000000000000000):
		print(-1)
	else:
		print(p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
integers=list(map(int,input().split()))
def multiply(integers):
  ans=1
  for i in integers:
    ans=ans*i
  if ans>10**18:
      return -1
  else:
      return ans

ans=multiply(integers)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

if __name__ == '__main__':
	n=int(input())
	l=list(map(int,input().split(" ")))
	c0=0
	p=1
	for i in range(n):
		p=p*l[i]
		if(p==0):
			break
	if(p>1000000000000000000):
		print(-1)
	else:
		print(p)