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
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
cur = 1
flag = 0
for i in range(N):
    a = A[i]
    cur *= a
if cur > MAX:
    flag = 1
if flag == 1:
    print(-1)
else:
    print(cur)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

sums=1
for i in A:
    sums=sums*i
if sums>1000000000000000000:
    print(-1)
else:
    print(sums)

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 = map(int, input().split())
A = list(map(int, input().split()))
ans = A[0]
if 0 in A:
    ans = 0
else:
    for a in A[1:]:
        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()))

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

ans = -1

if sum <= 10**18:
    ans = sum

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=list(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:
from functools import reduce
from operator import mul
n = int(input())
arr = list(map(int, input().split()))

ans = reduce(mul, arr)
print(-1 if ans > 10**18 else ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
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:
from functools import reduce
from operator import mul

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

m = reduce(mul, A)

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

Submission status: Time Limit Exceeded

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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = input()
As = list(map(int, input().split()))
ans = 1
inf = 10 ** 18
for a in As:
    ans *= a

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

Submission status: Time Limit Exceeded

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

if b>1e18:
    b=-1;
print(b)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    ans = 1
    for i in a:
        ans *= i
    INF = int(1e18)
    if ans > INF: 
        print(-1)
        return
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

if flag:
    print(ans)
else:
    if 0 in a:
        print(0)
    else:
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(j) for j in input().split()]
import functools
import operator

result = functools.reduce(operator.mul, A)
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()))
m = 1
for i in range(len(a)):
    m = m * a[i]
if m > 10 ** 18:
    print(-1)
    exit()
else:
    print(m)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = nl()
ans = 1
for ele in a:
    ans *= ele

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

if ans > INF:
    ans = -1


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

mult=1
array=map(int,input().split())

for i in array:
    mult*=i

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
arr=[int(i) for i in input().split()]
ans=1
for i in arr:
  ans*=i
if ans<=1000000000000000000:
  print(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
for i in A:
    ans*=i
if ans>mod:
    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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    big = pow(10, 18)
    ret = 1
    for a in A:
        ret *= a
    if ret > big:
        print(-1)
    else:
        print(ret)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

sum=1

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
N_list = [int(i) for i in input().split()]
res = 1
for i in range(len(N_list)) :
    res = res * N_list[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/local/bin/python3.5 -tt

import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield(int(i))

    g = _(sys.stdin)

    N = next(g)

    S = 1

    for i in range(N):
        A = next(g)

        S *= A

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    ans = 1
    for a in A:
        ans *= a
    if ans <= 10**18:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())


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

s=1
for i in A:
    s=s*i

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

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections


def main():
    max_n = 10**18
    n = int(input())
    a = input_list()
    ans = 1
    for v in a:
        ans *= v
    if ans > max_n:
        print(-1)
    else:
        print(ans)


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

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

ans = 1
sub = 10 ** 18

for i in a:
    ans *= i

if ans > sub:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

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 = input()
l = [int(each) for each in input().split()]
result = 1
for each in l:
    result *= each
if result > 10**18:
    result = -1
print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

ans = 1

for a in As:
    ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
    ans = ans*i
    if i==0:
        print('0')
        sys.exit()
if ans > 10**18:
    print('-1')
    sys.exit()
print(ans)

Submission status: Time Limit Exceeded

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

m = 1
for i in a:
    m *= i

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    MAX_V = 10 ** 18

    ans = 1
    for a in A:
        ans *= a
    if ans > MAX_V:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    from operator import mul
    from functools import reduce
    n, *a = map(int, open(0).read().split())
    b = reduce(mul, a)
    if b > 10 ** 18:
        print(-1)
    else:
        print(b)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from operator import mul, xor
from functools import reduce

def grow(arr):
    return reduce(mul, arr)

res = grow(A)
print(res) if res <= 10 ** 18 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)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import heapq
N = int(input())
a = list(map(int, input().split()))
ans = 1
max_ = pow(10, 18)
for tmp in a:
    ans *= tmp
if (ans > max_):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
A = [int(k) for k in input().split()]

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

print(-1 if M > 1e18 else M)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = map(int, args[1].split())

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

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Time Limit Exceeded

Solution code:

N = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in a:
    m = m * i
if m >10**18:
    print(-1)
else:
    print(m)

Submission status: Time Limit Exceeded

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

count = 1

for i in A:
    count *= i

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

Submission status: Time Limit Exceeded

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

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

p = 10 ** 18

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#TIME : 
import sys
from math import sqrt
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()))

n = inp()
a = inlt()
res = 1
for num in a:
    res*=num
if res > 10**18:
    print('-1')
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = tuple(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:
# B - Multiplication 2

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(int(x) for x in readline().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(0, n):
    ans *= a[i]
if ans <= 1_000_000_000_000_000_000:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

ans = 1

for i in h:
    ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(e) for e in input().split()]

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys


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


sys.setrecursionlimit(20000000)

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    answer = 1
    for i in range(N):
        answer *= A[i]

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
a  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = a[0]
for a_ in a[1:]:
    ans *= a_
print(-1 if ans > 10 ** 18 else ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
a = LI()
ans = 1
for ai in a:
    ans *= ai
    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 a in A:
  ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = reduce(mul,A)
lim = 10 ** 18
if ans > lim:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = list(map(int, input().split()))
ans = 1
for i in data:
    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 == 0:
        print('0')
        exit()
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 = map(int, input().split())
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:
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    ams=1
    for x in a:
        ams*=x

    if ams>pow(10,18):
        ams=-1

    print(ams)
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Submission status: Time Limit Exceeded

Solution code:
n = int(input().strip())
L = list(map(int, input().strip().split()))
ans=1
for v in L:
    ans*=v

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
n=int(input())
a= list(map(int, input().split()))
ans=1
for i in range(n):
    ans*=a[i]

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