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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
ans=1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    res = 1

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
for a in A:
    ans *= a
if ans > 10 ** 18:
    print(-1)
else:
    
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

#n = int(input())
#a,b = map(int,input().split())
a_L = list(map(int,input().split()))
ans = 1
for i in a_L:
    ans = ans*i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


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

    ans = 1
    for a in A:
        ans *= a
    
    return ans if ans <= 10**18 else -1


print(main())

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [el for el in map(int,input().split())]
res = 1
for el in A:
  res *= el
if res <= 10**18:
  print(res)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
a = LIST()
ans = 1
flag = 0 in a
for i in a:
    ans *= i
    if ans > 10 ** 18 and not flag:
        print(-1)
        exit()
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)
    exit()

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
# sys.setrecursionlimit(10**10)
N = int(sys.stdin.readline().rstrip())
# S = sys.stdin.readline().rstrip()
# N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()
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(x) for x in input().split()]
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()))
x = 1
for ai in a:
    x*=ai
if x>10**18:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,*A = get_all_int()

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

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

ans = 1

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

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()

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 sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

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


if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

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


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



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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
    ans*=i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

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

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

Submission status: Time Limit Exceeded

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

ans=1

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    ans = 1
    for ai in a:
        ans *= ai
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()

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: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    t = 1
    m = 10 ** 18
    for v in sorted(list(map(int, readline().split()))):
        t *= v
        if t > m:
            print(-1)
            exit()
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

ans=int(1)
for i in range(n):
    ans*=A[i]
    if(ans>1e18):
        print(-1)
        exit()

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

ans=int(1)

for i in range(n):
    ans*=A[i]
    if ans>1e18:
        print(-1)
        exit()
print(ans)

Submission status: Accepted

Solution code:
import sys

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

if(0 in A):
    print(0)
    sys.exit(0)

prod = 1
for a in A:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        sys.exit(0)

print(prod)

Submission status: Accepted

Solution code:
N = int(input())

A = list(map(int, input().split()))
B = 0
C = 1

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

for i in range(N):
    C = C * A[i]
    if C > 1000000000000000000:
        print(-1)
        exit()

print(C)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

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

max_ = 10 ** 18
N = ni()
A = na()
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > max_:
        ans = -1
        break
print(ans)

Submission status: Accepted

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

const = 10**18

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

result = 1
for i in A:
    result *= i
    if result>const:
        print(-1)
        exit(0)
print(result)

Submission status: Accepted

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

if 0 in A:
    print(0)
    exit()
product = 1
for num in A:
    product = product * num
    if product > 10 ** 18:
        print(-1)
        exit()

print(product)

Submission status: Accepted

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


def ans():
    if 0 in A:
        return print(0)
    product = 1
    for num in A:
        product = product * num
        if product > 10 ** 18:
            return print(-1)

    print(product)


ans()

Submission status: Accepted

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

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

Submission status: Accepted

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

if 0 in A:
  print(0)
  exit()
else:
  flag = True
  prd = 1
  A.sort(reverse=True)
  for i in range(N):
    prd *= A[i]
    if prd > 10**18:
      flag = False
      break
if flag:
  print(prd)
else:
  print(-1)

Submission status: Accepted

Solution code:
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 1

A = sorted(A)
for i in range(n):
    res *= A[i]
    if res > 10 ** 18:
        res = -1
        break
    if res == 0:
        break

print(res)

Submission status: Accepted

Solution code:
N = int(input())
CONST = 10 ** 18
result = 1
numbers = list(map(int, input().split()))
if 0 in numbers:
    print(0)
    exit(0)
numbers.sort(reverse=True)
for i in numbers:
    result = result * i
    if result > CONST:
        print(-1)
        exit(0)
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
v = [int(i) for i in input().split()]
if v.count(0) > 0:
    print(0)
    exit(0)
res = 1
for i in v:
    res *= i
    if (res > 10**18):
        print(-1)
        exit(0)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

if 0 in aa:
    print('0')
    exit(0)

result = 1
for a in aa:
    result *= a
    if result > pow(10, 18):
        print('-1')
        exit(0)

print(result)

Submission status: Accepted

Solution code:
num=int(input())
line=input().split(" ")
checklis=sorted(line)
if checklis[0]=="0":
    res=0
else:
    res=1
    i=0
    while res<=1000000000000000000 and i<num:
        res *= int(line[i])
        i+=1
        
    if res>1000000000000000000:
        res= -1
 
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=1
for i in[*open(0)][1].split():a=[-1,a:=a*int(i)][-1<a<=1e18]
print(a)

Submission status: Accepted

Solution code:
_,b=open(0);a=1
for i in b.split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

Submission status: Accepted

Solution code:
input();l=input().split();x=not"0"in l
for j in l:x=x*int(j)if 0<=x*int(j)<=1e18else-1
print(x)

Submission status: Accepted

Solution code:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

Submission status: Accepted

Solution code:
a,b=open(0);c=1;
for i in b.split():c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

Submission status: Accepted

Solution code:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-2<a-1<1e18]
print(a)

Submission status: Accepted

Solution code:
a,b=open(0);c=1;
for i in sorted(b.split()):c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

Submission status: Accepted

Solution code:
input();l=input().split();x=1
for j in sorted(l):
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
a=1;d=10**18
for i in[*open(0)][1].split():a=min(a*int(i),d+1)
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input();l=input().split();x=1
for j in sorted(l):
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
a,b=open(0);c=1;
for i in sorted(b.split()):c=[d:=int(i)*c,-1][10**18<d or c<0]
print(c)

Submission status: Accepted

Solution code:
input();l=input().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    x=-1;break
print(x)

Submission status: Accepted

Solution code:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:c=-1;break
print(c)

Submission status: Accepted

Solution code:
input();a=1
for i in input().split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)

Submission status: Accepted

Solution code:
i=input;i();l=i().split();x=not '0' in l
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)

Submission status: Accepted

Solution code:
input();a=1
for i in input().split():a*=int(i);a=[-1,a][0<=a<=eval('1'+'0'*18)]
print(a)

Submission status: Accepted

Solution code:
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a*=int(i);a=[-1,a][-1<a<=d]
print(a)

Submission status: Accepted

Solution code:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Submission status: Accepted

Solution code:
i=input;i();x=1;l=i().split()
if '0' in l:
  print(0)
  quit()
for j in l:
  x*=int(j)
  if x > 1e18:
    print(-1);quit()
print(x)

Submission status: Accepted

Solution code:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Submission status: Accepted

Solution code:
a=1;d=eval('1'+'0'*18)
for i in open(0).read().split()[1:]:a=min(a*int(i),d+1)
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a=min(a*int(i),d+1)
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input()
a=1
d=eval('1'+'0'*18)
for i in input().split():
  a=min(a*int(i),d+1)
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i),d+1)
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input()
a=1
d=1000000000000000000
for i in input().split():
  a*=[int(i),1][(a>d)*(i!='0')]
print([a,-1][a>d])

Submission status: Accepted

Solution code:
input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i), d+1)
print([a,-1][a>d])

Submission status: Accepted

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

ans = 1

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

for i in a:
    ans = ans * i
    if ans > 1e18:
        print(-1)
        exit()

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1

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

for i in A:
    ans = ans * i
    if ans > 1e18:
        print(-1)
        exit()

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
As = [int(num) for num in input().split()]

As_sorted = sorted(As, reverse=True)
if As_sorted[-1] == 0:
    print(0)
else:
    flag = False
    res = 1
    for num in As_sorted:
        res *= num
        if res > 10**18:
            flag = True
            break            
    if flag:
        print(-1)
    else:
        print(res)

Submission status: Accepted

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n=int(input())
ar=lis()
if 0 in ar:
    print(0)
    quit()
p=1
for i in range(n):
    p*=ar[i]
    if p>10**18:
        print(-1)
        quit()
print(p)

Submission status: Accepted

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

Submission status: Accepted

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