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 = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
if ans > 1000000000000000000:
        print(-1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
for a in A:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        quit()
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 > 1000000000000000000:
        print(-1)
        quit()
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 len(str(ans))>19:
        print(-1)
        quit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
m = 1
threshold = 1e18
for i in a:
    m *= i
    if m >= threshold:
        m = -1  
        break
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = 1
threshold = 1e18
for i in a:
    m *= i
    if m >= threshold:
        m = -1
        break
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= lists[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 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()))
sorted(a,reverse=True)
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()))
c = 1
for a in A:
    c *= a
    if c > 10**18:
        print("-1")
        quit()
print(c)

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1

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

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Submission status: Wrong Answer

Solution code:
R = input().split()
huga = input().split()
i=0
a=""
go=1
"""for c in huga:
    a=a+c
if len(a)>20:
    print("-1")
else:"""
for b in huga:
    go=go*int(b)
if len(str(go))>=19:
    print("-1")
else:
    print(go)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while data[-1] == 0:
  data.insert(0,0)
  data.pop(-1)
 
ans = 1

for d in data:
  ans = ans * int(d)
  if ans > 10*18 or ans == 0:
    break
 
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

if data[-1] == 0:
  ans = 0
  pass
else:
  for d in data:
    ans = ans * int(d)
    print(ans)
    if ans > 10**18:
      break
 
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=map(int,input().split())
for l in A:
  l*=l
if l<=1000000000000000000:
  print(l)
else:
  print("-1")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=map(int,input().split())
for l in A:
  l*=l
if l<1000000000000000000:
  print(l)
else:
  print("-1")

Submission status: Wrong Answer

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

res = 1

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

Submission status: Wrong Answer

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

res = 1
for i in range(n):
  res = res * nums[i]
  if res <= 10**18:
    continue
  else:
    res = -1
    break
    
print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# B Multiplication 2

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

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(-1)
    exit()

if ans > 10**18:
  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>=1000000000000000000:
  ans = -1

print(ans)

Submission status: Wrong Answer

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

ans = 1
for num in nums:
    ans *= num
    if ans > 1e18:
        break

print(ans if ans < 1e18 else -1)

Submission status: Wrong Answer

Solution code:
N = input()
nums = map(int, input().split())
ans = 1
for num in nums:
  ans *= num

print(ans if ans < 1e18 else -1)

Submission status: Wrong Answer

Solution code:
import sys
N=31
A=[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]
if 0 in A:
    print(0)
    sys.exit()

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

print(prod)

Submission status: Wrong Answer

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

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10**18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)

Submission status: Wrong Answer

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

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)

Submission status: Wrong Answer

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

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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)

print(np.prod(a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n-1):
  s += a[i]*a[i+1]
print(s)

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(N):
    if A[i] == 0:
        ans = 0
        break
    
    else:
        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
for i in range(N):
    if A[i] == 0:
        ans = 0
        break
    else:
        ans *= A[i]
  
if ans < 1000000000000000000:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from math import log2
lt = log2(10**18)

if ary[0] == 0:
  print(0)
  
elif any(log2(ary[i]) > lt / (n-i) for i in range(n)):
  print('-1')

else:
  prod = 1
  for i in range(n):
    prod *= ary[i]
  print(prod)

Submission status: Wrong Answer

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

ans = 1

for d in data:
  ans = ans * int(d)
  if ans >= 10**18:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
s=1
d=1
for i in l:
    s=s*i
    if(s>10**18):
        print(-1)
        d=0
        break
if(d==1 and n!=1):
    print(s)
else:
    print(l[0])

Submission status: Wrong Answer

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

ans = 1

for d in data:
  ans = ans * int(d)
  if ans > 10**18:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
error = False

for d in data:
  ans = ans * int(d)
  if ans > 10**18:
    error = True
    break

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

Submission status: Wrong Answer

Solution code:
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1
def powerMod(x,y,p):
    res=1
    x%=p
    while y>0:
        if y&1:
            res=(res*x)%p
        y=y>>1
        x=(x*x)%p
    return res
def gcd(x,y):
    while y:
        x,y=y,x%y
    return x
def isPrime(n):
    if(n<=1): return False
    if(n<=3): return True
    if(n%2==0 or n%3==0): return False
    i=5
    while(i*i<=n) : 
        if(n%i==0 or n%(i+2)==0) : 
            return False
        i=i+6
    return True
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def main():
    n=int(input())
    prod = 1
    arr=list(map(int,input().split()))
    for i in arr:
        prod = prod*i
        if(prod>=1e18):
            print(-1)
            return
    print(prod)

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *
#import threading
#from itertools import permutations
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1
def powerMod(x,y,p):
    res=1
    x%=p
    while y>0:
        if y&1:
            res=(res*x)%p
        y=y>>1
        x=(x*x)%p
    return res
def gcd(x,y):
    while y:
        x,y=y,x%y
    return x
def isPrime(n):
    if(n<=1): return False
    if(n<=3): return True
    if(n%2==0 or n%3==0): return False
    i=5
    while(i*i<=n) : 
        if(n%i==0 or n%(i+2)==0) : 
            return False
        i=i+6
    return True
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def main():
    n=int(input())
    prod = 1
    arr=list(map(int,input().split()))
    for i in arr:
        prod = prod*i
        if(prod>1e18):
            print(-1)
            return
    print(prod)

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[-1]==0:
    print(0)
    exit()
ans=a[0]
for i in range(len(a)-1):
    if ans>1000000000000000000:
        print(-1)
        exit()
    ans*=a[i+1]
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
a = int(input())
b = list(map(int, input().split()[:a]))
c = numpy.prod(b)
if c > 10**18:
    print(-1)
else:
    print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

product = 1

for num in nums:
    product *= num

    if product > 1e18:
        product = -1
        break

print(product)

Submission status: Wrong Answer

Solution code:
a= input()
list1 = input()
x = [int(i) for i in list1.split()]
mult = 1

for i in x:
    
    mult = mult * i

mult_str = str(mult)
num_lst = list(mult_str)


if len(num_lst) > 18:
    print(-1)
else:
    print(mult)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
an = [int(num) for num in input().split()]

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

answer = an[0]
check = 10**18
for i in range(1,len(an)) :
  answer *= an[i]
  if answer >= check:
    print(-1)
    sys.exit()

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(result)

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] * result
  
if result >= 10000000000000000000:
  result = -1

print(result)

Submission status: Wrong Answer

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

for i in a:
  result = i * result
  
if result >= 1000000000000000000:
  result = -1

print(result)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

prod = A.prod()

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

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

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()))
T=np.prod(A)
 
if T<10**18: 
    print(T)
else:
    print(str(-1))

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return

    ans=1
    for i in A:
        ans*=i
        if ans>1000000000000000000:
            print(-1)
            return

    print(ans)

Submission status: Wrong Answer

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

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()))
L=10**18
ans=A[0]
for i in range(1,N):
    ans*=A[i]
print(ans if ans<L else -1)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

MAX = 10**18
result = 1
for i in input().split():
    result *= int(i)
    if result > MAX:
        print(-1)
        exit()

print(result)

Submission status: Wrong Answer

Solution code:
#import 
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

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