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: Wrong Answer

Solution code:
n = input()
list = [int(x) for x in input().split(" ")]
result = 1
for i in range(len(list)):
    result = result*list[i]

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

Submission status: Wrong Answer

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)
    break
else:
  print(c)

Submission status: Wrong Answer

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

lim = 10**18

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

print(T)

Submission status: Wrong Answer

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

res = 1
for i in l:
    res *= i
    if res > 1e18:
        res = -1
        break

print(res)

Submission status: Wrong Answer

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

s = 1
ten18 = 10**18
over = False

for b in a:
  s *= b
  if s > ten18:
    print(-1)
    over = True
    break
if not over:
	print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def mul2():
    n = int(input())
    nums = list(map(int,input().split()))
    limit = 10**8
    res = 1
    for num in nums:
        res *= num
    if res > limit:
        return -1
    return res

if __name__ == "__main__":
    print(mul2())

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
dekai = False
for a in A:
    ans *= a
    if ans > (10 ** 18):
        dekai = True
        break

if dekai:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if ans <= 10**18 :
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans=np.prod(a)
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    ans = 1
    for i in a:
        if i == 0:
            ans = 0
            break
        elif ans * i > 10 ** 18:
            ans = -1
            break
        else:
            ans *= i

    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for num in nums:
    ans = ans * num
    if ans > 10**18:
        break
if ans > 10**18:
    print('-1')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

ans = 1
for i in range(N):
  ans *= a[i]
  if ans > int(1e18):
    print(-1)
    break
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

res = 1
for i in A:
    if res > 10**18:
        print(-1)
        sys.exit()
    res *= i

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

Submission status: Wrong Answer

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

p = 1
limit = 10 ** 18
for a in A:
    p *= a
    if p > limit:
        print(-1)
        exit()
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for i in arr:
    if i == 0:
        print(0)
        sys.exit()
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()

else:
    print(ans)

Submission status: Wrong Answer

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

if (flag):
    ans = -1
if 0 in a:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mul = 1
for i in range(n):
    mul *= a[i]
print(mul if mul < 1e18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import log10
N = int(input())
A = map(int, input().split())

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

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

Submission status: Wrong Answer

Solution code:
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
i = 0
ais.sort(key = lambda x:-x)
while(i < len(ais) and cumul < 10 ** 18):
  cumul *= ais[i]
  i +=1
  if cumul == 0:
  	break
print cumul if cumul < 10 ** 18 else -1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

main()

Submission status: Wrong Answer

Solution code:
from functools import reduce

mul = lambda x, y: x*y
ret = reduce(mul, map(int, input().split()), 1)

if 10**8 < ret:
  print(-1)
else:
  print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(x) for x in input().split()]
counter = 0
a = 1
for i in range(n):
  if counter == 1:
    break
  else:
    a = a * l[i]
    if a > 10 ** 18:
      counter +=1
if counter == 0:
  print(a)

Submission status: Wrong Answer

Solution code:
def main() :

    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)
            return
    
    print(res)

main()

Submission status: Wrong Answer

Solution code:
a=int(input())
mul=1
for i in range(a):
  mul=mul*a
if mul>1000000000000000000:
  print('-1')
else:
  print(mul)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
a.sort()
ans = 1
for aa in a:
    ans *= aa
    if ans > 10 ** 18:
        print(-1)
        exit()
print(len(str(ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)
else:
  print(S)

Submission status: Wrong Answer

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

if min(a) == 0:
    print(0)
    exit()
else:
    ans = a[0]
    for i in range(1, n, 1):
        ans = ans * a[i]
        if ans > 1e+18:
            print(-1)
        else:
            print(ans)

Submission status: Wrong Answer

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

ans = 1
for a in l_a:
    ans *= a
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
print(np.prod(a) if np.prod(a) <= 10**18 else '-1')

Submission status: Wrong Answer

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)
        break
else:
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
tmp = 1
flg = 1
for i in range(n):
    tmp *= a[i]

if flg:
    print(tmp)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.prod(a)
if(ans > 10**18):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in a:
    ans = ans*i

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1
    for jj in j:
        res *= jj
        if math.pow(10, 18) < res:
            print(-1)
            return 0

    print(res)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
x = 1
for i in range(n):
    x *= a[i]
    # print(i,x)
    if x > 10**18:
        print(-1)
        quit()
print(x)

Submission status: Wrong Answer

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

ans = np.prod(a)
if ans > 10**18:
  print('-1')
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for i in range(len(a)):
  if ans > 10**18:
    print(-1)
    exit()
  else:
    ans *= a[i]
    
if ans > 10**18:
  print(-1)
  exit()
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
MAX_VAL = 10 ** 18

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

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    if 0 in a:
        print('0')
        exit()
    ans = 1
    for hoge in a:
        print(ans)
        ans *= hoge
        if ans >= 10**18:
            print('-1')
            exit()
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a = int(input())
A = [int(i) for i in input().split()]
total = 1
for i in range(a):
    total *= A[i]
if total>10**14:
    total = -1
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tot=1
for a in line:
	tot*=int(a)
	if tot>10**18:
		tot=-1
		break
print(tot)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
ans=1
flag=True
for i in A:
    ans*=i
    if ans>10**18:
        flag=False
        break
print(ans if flag==True else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))
A = np.array(A)
ret = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
for i in x:
    prod *= i
    if prod == 0:
        print(0)
        exit()
    if prod > ele:
        print(-1)
        exit()
print(prod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

import numpy as np

p = np.prod(List)

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

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1
for A in As:
    ans = ans * A
    if ans >= 10**18:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n = inp()
    a = inlt()
    q = 1
    for i in range(n):
        q = q * a[i]
        if q > 10 ** 18:
            q = -1
            break
    print(q)
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))

#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
array = list(map(int, input().strip().split()))
x=1
l=len(array)
for i in range (l):
    x*=array[i]
    if x>1000000000000000000:
        x=-1
        break
print(x)

Submission status: Wrong Answer

Solution code:
import sys
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1

    mo = pow(10, 18)
    for i in range(n):
        if a[i] > mo // ans:
            print(-1)
            sys.exit(0)
        else:
            ans *= a[i]
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())

X=list(map(int,input().split()))
result=1
for i in X:
  result*=i
  if result>10**18:
    result=-1
    break

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

print(Ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = A[0]

for n in range(1,N):
  ans = ans * A[n]
  if ans > 10**18:
    print(-1)
    exit()

print(ans)

Submission status: Wrong Answer

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')
        exit(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import copy
from collections import deque
import heapq
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
ans = 1
if a[0] == 0:
    print(0)
    exit()
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = np.prod(a)
if p > 10**18:
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
limit = 10**18+1

mul = 1
for i in A:
    mul *= i
    if mul >= limit:
        print("-1")
        break

if mul < limit:
    print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for a in a_li:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        exit()

print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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
    break
print(s)

Submission status: Wrong Answer

Solution code:
import numpy

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

p = numpy.prod(A_list)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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
        break
print(s)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-05-31 20:58:43 +0900
# LastModified: 2020-05-31 21:04:01 +0900
#


import os
import sys
import numpy as np
#import pandas as pd


def main():
    n = int(input())
    a = list(map(int,input().split()))
    if np.prod(a)>10**18:
        print("-1")
    else:
        print(np.prod(a))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


LIMIT = 10 ** 18


def prod(xs):
    res = 1
    for x in xs:
        res *= x
        if res > LIMIT:
            return None
    return res


def main():
    n = int(input())
    bs = [int(z) for z in input().split()]
    res = prod(bs)
    if res is None:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    main()