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:
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil, factorial, log,tan,pi,cos,sin,radians
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
from fractions import Fraction
from functools import reduce
from decimal import *
import string
import sys
import os
import re
inf = float('inf')
mod_ = int(1e9) + 7
mod = 998244353

def factors(n):
    from functools import reduce
    return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sieve(m):
    n=1
    primes = {}
    arr=set([])
    for i in range(2, int(m ** 0.5) + 1):
        a = n // i
        b = m // i
        for k in range(max(2, a), b + 1):
            c = i * k
            primes[c] = 1

    for i in range(max(n, 2), m + 1):
        if i not in primes:
            arr.add(i)

    return arr


class DisjointSetUnion:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
 
    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a
 
    def union(self, a, b):
        a, b = self.find(a), self.find(b)
        if a != b:
            if self.size[a] < self.size[b]:
                a, b = b, a
 
            self.num_sets -= 1
            self.parent[b] = a
            self.size[a] += self.size[b]
 
    def set_size(self, a):
        return self.size[self.find(a)]
 
    def __len__(self):
        return self.num_sets



def main():
    n=int(input())
    prod=1
    arr=list(map(int,input().split()))
    for i in arr:
        prod*=i
        if prod>10**18:
            print(-1)
            exit()
    # if i>10**18:
    #     print(-1)
    #     exit()
    print(prod)
    # n,m=
    # print(n*m)












    



# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

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


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    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()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
now = 1
for one in a:
    now *= one
    if now > 1e18:
        print("-1")
        exit()
print(now)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in A:
    res *= i
    if res > 10**18:
        print(res)
        res = -1
        break
if A.count(0) != 0:
    res = 0
print(res)

Submission status: Wrong Answer

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

LIMIT = 10 ** 18
result = 1


for a_i in list(a_n):
    result = result * a_i

    if result > LIMIT:
        result = -1
        break
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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> 1000000000000000000:
            ams=-1
            break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = list(map(int,input().split()))
prod = 1
for i in lis:
    if(prod>1000000000000000000):
        print(-1)
        exit(0)
    prod=prod*i
print(prod) if(prod<=1000000000000000000) 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==0:break
    if ans > 10 ** 18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

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

def main(kwargs):
    n = kwargs["n"]
    A = kwargs["A"]
    res = 1

    for i in range(n):
        res *= A[i]

        if res > 10 ** 18:
            res = -1
            break

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

total = a[0]

if  10 ** 18 < N:
    print(-1)
else:
    for i in range(1,N):
        total *= a[i]
    print(total)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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 > 1e18:
    print(-1)
    exit(0)
print(ans)

Submission status: Wrong Answer

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    ans = 1
    if 0 in As:
        print(0)
        exit()

    for i in range(n):
        ans *= As[i]
        if ans > 10**18:
            ans = -1
        break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

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

if ans>100000000:
    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>1000000000000000000:
    print("-1")
    sys.exit()
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
    if(ans > 1000000000000000000):
      print("-1")
      quit()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())

strs = input().split()
sum = 1
out_range = False
for i in range(n):
  v = int(strs[i])
  if(not out_range):
    sum *= v
  if(not out_range and sum > 10e18):
    out_range = True
  if(v == 0):
    print(0)
    sys.exit()

if(not out_range):
  print(sum)
else:
  print(-1)

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:
#B
N = int(input())
A = map(int,input().split())
r = 1
for i in A:
    r = r*i
    if r > 10**18:
        r = -1
        break
    else:
        pass
print(r)

Submission status: Wrong Answer

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

result = 1
for a in alist:
  if result > 10**18:
    break
  result = result*a
print(result)

Submission status: Wrong Answer

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

for i in A:
  if ans <= 10**18:
    ans *= i
  else:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))

if A.count(0) > 0:
    print(0)
else:
    x = np.prod(A)
    if x > 1000000000000000000:
        print(-1)
    else:
        print(x)

Submission status: Wrong Answer

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

maxi = int(1e18)

ans = 1
for x in a:
    ans *= x
    if ans > maxi:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
numList = list(map(int, input().split()))
product = 1
toPrint = True
for i in numList:
    product *= i
    if product > 10**18:
        toPrint = False
        break
if toPrint:
    print(product)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

input()
a = np.array(list(map(int, input().split())))
b = np.prod(a)
if b > 10 ** 18:
    print(-1)
else:
    print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
printed = False
for x in a:
    ans *= x
    if ans > 1e18:
        print(-1)
        printed = True
        
        
    
if not printed:
    print(ans)

Submission status: Wrong Answer

Solution code:
from sys import exit

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

tmp=1
for a in A:
	tmp*=a
	if tmp>10**8:
		print("-1")
		exit()

print(tmp)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

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

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

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True


n=input1()
A=input_array()
ans=1
flag=True
for a in A:
	ans=ans*a
	if ans > 10**18:
		print(-1)
		flag=False
		break
	if ans==0:
		break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = 1
for i in lis:
    ans *= i
    if ans > 10**18:
        flag = -1
        break

if flag == 1:
    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(N):
    ans *= A[i]

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

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 >pow(10,18):
        print(-1)
        break
    elif i == (n-1):
        print(ans)
    else:    
        continue

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
import random
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
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)]
mod = 1000000007

def main():
	n = I()
	A = np.array(LI())
	product = np.prod(A)
	if product > 10**18:
		print(-1)
	else:
		print(product)




if __name__ == '__main__':
    main()

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 > 1000000000000000000:
        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 sorted(A, reverse=True):
    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 = int(input())
A = list(map(int,input().split(" ")))
ans = A[0]
max_ans = 10 ** 18
if 0 in A:
    ans = 0
else:
    for i in range(1,len(A)):
        ans *= A[i]
        if ans >= max_ans:
            ans = -1
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s=1
over=False
for i in ls:
    s*=i
    if s>10**18:
        over=True
        break


if over:
    print(-1)
else:
    print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
ans=1
for x in a:
    ans*=x
    if ans>1e18:
        break
if ans>1e18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

n = int(input())

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

k = 1

for i in l:
    k = k*i
    if k > 10**18:
        print(-1)
        exit()
    if k == 0:
        print(k)
        exit()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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

    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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)
    break
if not ans>10**18:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def main(A):
    ans = 1
    for i in A:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
    return ans


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for k in a:
    if k == 0:
        print(0)
        exit()

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


print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

Alist = [int(x) for x in input().split(" ")]
if len(Alist) != N:
  print("-1")
  exit()

result = 1
for a in Alist:
  result *= a
  if result > 10**18:
    print("-1")
    exit()
print(result)

Submission status: Wrong Answer

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

f=1
for i in range(a):
   
    f *= b[i]
print(f if f <10**18 else '-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

for i in l:
    ans *= i
    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()))
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:
n = int(input())
ar = list(map(int,input().split()))
ans=1
for i in ar:
    ans*=i
    if ans>1e18:
      break
if ans>1e18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
# from random import choice,randint
# from bisect import bisect_left as bl             
# from bisect import bisect_right as br  
# from collections import deque,defaultdict,Counter
# from math import sqrt,floor,ceil
# from itertools import combinations,permutations
# from heapq import heapify,heappop,heappush,heappushpop
# inp=sys.stdin.readline
# out=sys.stdout.write
# flsh=sys.stdout.flush
# ranomd string generator --> a = ''.join(random.choices(string.ascii_lowercase, k = 1000))
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod1=998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

#fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()] #use list comprehension for loops
def LF(): return [float(x) for x in inp().strip().split()] #use try and except for dictionaries
def LS(): return inp().strip().split() #declare local variables ... for functions assing them to variables
def I(): return int(inp().strip()) # before using example ... func = len for using len() funtcion
def F(): return float(inp().strip()) #sort dictionary after zipping
def S(): return inp().strip() #use map function for mapping list to a fuction
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a)) #use this for string concatenation
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r,p):                      
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

####################Actualcode################################
def solve():
    n = I()
    a=LI()
    p = 1
    flag=0
    for i in a:
        p*=i
        if p>10**18:
            flag=1
            break

    if p>10**18 or flag==1:
        print(-1)
    else:
        print(p)
def main():
    solve()

######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

inp = lambda: sys.stdin.readline().rstrip('\r\n')
out = lambda x: sys.stdout.write(x)
flsh= lambda: sys.stdout.flush()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = map(int,input().split())
total = 1
for i in l:
    total *= i

if total >= 1000000000000000000 :
    total = -1

print(total)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
ans = 1
for i in a:
  ans = ans * int(i)
  if ans>1000000000000000000:
    ans = -1
    break
print(ans)