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:
# coding: utf-8
a = int(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 = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        print(0)
        exit()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mul = 1
for ele in a:
    mul *= ele
print(mul if mul <= 1e18 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for  i in range(1,n):
    ans = ans * a[i]
if ans <= check:
    print(ans)
else:
    print('-1')

Submission status: Time Limit Exceeded

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

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

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

        return ans


if __name__=="__main__":
        ans = main()
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = reduce(lambda x,y: x*y, a)
if res > m:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:

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

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

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

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

Submission status: Time Limit Exceeded

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

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

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

print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if result > 1000000000000000000 :
    print("-1")
else:
	print(result)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in list_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 > 1e18:
        print(-1)
        exit()

print(ans)

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for num in A:
    ans *= num

if ans > 1e18:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
for x in things:
	result *= x

print(-1) if result > big else print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = map(int, input())

ans = 1
for i in input().split():
    ans *= int(i)

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()))
num = 1
for i in a_list:
  num *= i
print(num if num <= 10**18 else "-1")

Submission status: Time Limit Exceeded

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

s = 1
for i in mlist:
    s *= int(i)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = map(int, input().split())
zero = False
ans = 1
ok = True
for e in arr:
	if e == 0:
		zero = True
	ans = ans * e;
	if ans > 10**18:
		ok = False
if zero:
	print(0)
else:
	if ok:
		print(ans)
	else:
		print(-1)

Submission status: Time Limit Exceeded

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

for i in range(len(li)):
  a = li[i]
  b *= a

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

Submission status: Time Limit Exceeded

Solution code:

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

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(n):
    ans *= a[i]


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = input()
A = list(input().split())
num = 1
for i in A:
  num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce  
n = int(input())
l = list(map(int, input().split()))
res = reduce((lambda x, y: x * y), l) 
if(res > 10**18):
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
a=1
n=int(input())
li = list(map(int, input().split()))
for i in range(n):
    a=a*li[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()))
count = A[0]
for i,v in enumerate(A):
    if i != 0:
        count = count * v
if 10 ** 18 < count:
    count = -1
print(count)

Submission status: Time Limit Exceeded

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

count = 1

for i in range(N):
    if A[i] == 0:
        print(0)
        exit()

    count *= A[i]

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

f = functools.reduce(operator.mul, a)
 
if  f<=10**18:  
    print(f)  
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 = ans * a[i]
    
if ans > 10**18:
  print(-1)
else:  
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

a_list = [0 for i in range(n)]
a_list = line.split(" ")
a_list = [int(a) for a in a_list]

ans = 1

for a in a_list:
    ans = ans * a

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n = int(rl())
a = list(map(int, rl().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())
list = [b for b in input().split()]
a = 1
for l in range(N):
    a = a*int(list[l-1])
if a > 10**18:
    print(-1)
else:
    print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = int(input())
li = list(map(int,input().split()))
ans = functools.reduce(operator.mul, li)
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()))
INF = 10**18
ans = 1
for e in a:
    ans*=e

if ans > INF:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
h = input().split()

#print(num)
#print(h)
ans = 0

for i in range(num):
    if i == 0:
        ans = ans + int(h[i])
    else:
        ans = ans * int(h[i])
if ans > 1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = int(input())
a = list(map(int,input().split()))

if 0 in a:
	print(0)
else:
	M = 10**18
	ans = reduce(mul, a)
	if ans > M:
		print(-1)
	else:
		print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
A = [int(x) for x in input().split(" ")]
product = 1
for a in A:
    product = product * a
if product > 10 ** 18:
    print(-1)
    sys.exit(0)

print(product)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import functools
import operator

result = functools.reduce(operator.mul, lis)
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()]
x=1
P=10**18
for a in A:
  x*=a
if x>P:x=-1
print(x)

Submission status: Time Limit Exceeded

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

if 0 in A:
    print(0)
elif max(A) >= 10**18:
    print(-1)
else:
    for i in A:
        B *= 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=A.pop(0)
for i in A: ans=ans*i
print(ans if ans<=10**18 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if (ans > 1000000000000000000):
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = int(input())
a = list(map(int, input().split()))
ans = functools.reduce(operator.mul, a)
print(ans if ans <= 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 range(n):
    ans *= a[i]

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

b = int(input())
a=[int(x) for x in input().split()]

mm = reduce(lambda x, y: x * y, a) 

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
LIMIT = 1000000000000000000

def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト
    answer = 1

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    elif 0 in l:
      ans = 0
      break
    else:
      continue

print(ans)

Submission status: Time Limit Exceeded

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

ans = S[0]
S.pop(0)

for num in S:
    ans *= num

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

ans = A[0]

for i in range(1, N):
    if A[i] == 0:
        print(0)
        exit()
    ans = ans * A[i]

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

Submission status: Time Limit Exceeded

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

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

if 0 in A:
    start_idx = max(
        [
            idx
            for idx, a in enumerate(A)
            if a == 0
        ]
    ) + 1

    if start_idx == N:
        print(0)
        exit(0)
else:
    start_idx = 1

for i in range(start_idx, N):
    res *= A[i]

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(a) for a in 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 = a[0]*a[1]

for i in range(len(a)-2):
  ans *= a[i+2]
if ans > 1e18:
  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()))

sum=1
for _ in A:
    sum*=_

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

sum_num = reduce(mul, input_list)

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

Submission status: Time Limit Exceeded

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

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:
from operator import mul
from functools import reduce
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
c = reduce(mul, a)
if c > (10**18):
    print(-1)
else:
    print(reduce(mul, a))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ar = input().split()
res = 1
for x in ar:
    x = int(x)
    res *= x
if res > 1000000000000000000:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 1
flag = 0

lim = 10 ** 18

alay = list(map(int, input().strip().split(' ')))

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

if ans > lim:
    flag = 1
    print('-1')

if flag == 0 :
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
N=int(input())
A=deque([*map(int,input().split())])
a=1
while A:
  a*=A.popleft()
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 i in range(n):
    ans = ans * a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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())
prod=1
arr=list(map(int,input().split()))
for i in range(n):
    if arr[i]==0:
        prod=0
        break

    prod*=arr[i]

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

Submission status: Time Limit Exceeded

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

INF=1000000000000000000

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

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

Submission status: Time Limit Exceeded

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

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

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

print(answer)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input().rstrip())
list = input().rstrip().split(' ')

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

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
ans = 1
cur = input().split()
for i in cur:
    ans*= int(i)

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

Submission status: Time Limit Exceeded

Solution code:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
from operator import mul
from functools import reduce
 
ans = reduce(mul, A) #結果=>120
 
if ans > 10**18 :
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = (map(int,list(input().split())))
tmp = 1
for i in A:
    tmp = tmp * i
    if tmp == 0:
        print(tmp)
        quit()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = 1
    for m in lst :
        output *= m
    if output <= 1000000000000000000 :
        print(output)
    else :
        print(-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
for i in range(N):
    A[i] = int(A[i])
sum = 1

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

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

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の入力
N = int(input())

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10 ** 18:
            result = -1
print(result)

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 = ans * A[i]

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

print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(int,input().split()))
ans = A[0]


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



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

else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:


N = int(input())
t = [0] * N
li = list(map(int, input().split()))
k = 1
for i in range(len(li)):
    k = k * li[i]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Ai = [0] * N
Ai = list(map(int,input().split()))
Ans = 1

for i in range(N):
  if Ai[0] == 0:
    Ans = 0
    break
    
  Ans = Ans * Ai[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()))

results = A[0]
can = True
zero = False
for i in range(N):
    if A[i]==0:
        zero = True
        break

for i in range(N):
    if i==0:
        continue
    results *= A[i]
    if zero:
        continue
    else:
        if results>10**18:
            can = False
            break

if can:
    print(results)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
def product(list):
    i=1
    for j in list:
        if j!=0:
            i*=j
        else:
            return 0
    return i
 
N=int(input())
A=list(map(int,input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
flag = False
zeros = False
over = pow(10,18)
for i in a:
    ans *= i
    if (ans > over):
        flag = True
    if i == 0:
        zeros = True

if (flag):
    ans = -1
if (zeros):
    ans = 0

print(ans)