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

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

Submission status: Wrong Answer

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

result = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    mul = 1
    for a in A:
        mul*=a
        if mul>10**18:
            mul=-1
            break
    
    print(mul)
main()

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())
arr=list(map(int,input().split()))
mul=1
for i in range(n):
	mul=mul*arr[i]
	if(mul>10**18):
		print("-1")
		exit(0)
print(mul)

Submission status: Wrong Answer

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

for i in A:
    i = i / (10 ** 18)
    ans * i

print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
x_min = min(a)
if x_min == 0:
    print(0)
else:
    for x in a:
        ans *= x
        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()))

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

resolve()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = 1
lim = 10**18
for e in l:
    n *= e
    if n > lim:
        print(-1)
        break
else:
    print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

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

    return str(ret)


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

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

Submission status: Wrong Answer

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

ans = 1

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
*arr, = map(int, input().split())
res = 1
for i in range(n):
    res *= arr[i]
print(res)

Submission status: Wrong Answer

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

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

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

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]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    
if res < 10 ** 18:    
    print(res)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math
l1=list(map(int,input().split()))
a=math.prod(l1)
if a>=10**18:
  print("-1")
else:
  print(a)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import random
import collections

# available on Google, not available on Codeforces
# import numpy as np
# import scipy
import math


def solve(lst):  # fix inputs here
    # console("----- solving ------")

    res = 1
    for r in lst:
        res *= r
        if res > 10**18:
            return -1

    return res

def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return


# for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
_ = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer

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

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(input())

res = solve(lst)

    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**18 or s< 0:
    flg = True
    break
if flg:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=0
con=1
mod=10**18
ans=1
while con==1:
  ans=ans*a[i]
  i+=1
  if ans>mod:
    con=0
    ans=-1
  elif i==n:
    con=0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
    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()))
Total = 0
for i in a:
  Total *= i
if Total > 10e18:
  print('-1')
else:
  print(Total)

Submission status: Wrong Answer

Solution code:
def sol():
    n = int(input())
    mul = 1
    arr = list(map(int, input().split()))
    for i in arr:
        mul*=i
        if(mul>10**18):
            print(-1)
            return
    print(mul)
sol()

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n=read()
res=1
mod=10**18
a=list(reads())
for i in range(n):   
    res*=a[i]
    if res>mod:
        print("-1")
        exit()
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(N, A):
    ret = 1
    upper = 10**18
    for a in A:
        ret *= a
        if upper < ret:
            return -1
    return ret

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Submission status: Wrong Answer

Solution code:
p=int(input())
k=list(map(int,input().split()))
t=1
for e in k:
    t = t*e
    if t>10**8:
        break
if t>10**8:
    print(-1)
else:
    print(t)

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
print cumul if cumul < 10 ** 18 else -1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(i) for i in input().split()]
total=1
for i in range(n):
    if(arr[i]>10**18):
        total=-1
        break
    else:
        total*=arr[i]
        if total>10**18:
            total=-1
            break
print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(m)

Submission status: Wrong Answer

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

ans = 1
for i in a:
    if i == 0:
        ans = 0
        break
    else:
        ans *= i

if ans * i > 10 ** 18:
        ans = -1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

LIMIT = 10**18

result = 1
for a in As:
    result *= a
    if a > LIMIT:
        result = -1
        break

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int,input().split()))
ans = 1
inf_ = 10**18
f = 0
for i in range(len(num)):
    ans *= num[i]

if(ans >=inf_):
    f = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import collections

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

if np.prod(A) > pow(10, 18):
    print(-1)
else:
    print(np.prod(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(A):
    x = 1

    for a in A:
        x *= a
        if x > 10**18:
            return -1

    return x

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = tuple(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
    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 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 = 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
inf=10**18
for i in a:
  ans*=i
  if ans>inf:
    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)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
    ans *= i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lt = [int(x) for x in input().split()]

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    def solve():
        ans = 1
        for aa in a:
            ans *= aa
            if ans >10**18:
                return -1
        return ans
    print(solve())
        
    
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 *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()


print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    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)
            return

    print(ans)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit

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:
N = int(input())
A = list(map(int, input().split()))

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(prod)

Submission status: Wrong Answer

Solution code:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

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

Submission status: 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=list(map(int,input().split()))
if 0 in A:
  print(0)
c=1
for i in range(len(A)):
  c*=A[i]
  if c>10**18:
    print(-1)
    exit()
    
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = [int(a) for a in input().strip().split()]

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
a = LI()

tmp = 1
for i in range(n):
    if pow(10,18)<tmp*a[i]:
        print(-1)
        exit()
    else:
        tmp *= a[i]

print(tmp)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

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

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

    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()))
mul=1
for i in range(n):
       mul*=a[i]
       
print(mul)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for num in A:
    ans *= num
    if ans == 0:
        break
    elif ans > 1e18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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