Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Wrong Answer

Solution code:
N = input()
A = list(map(int, input().split()))
 
result = 1 
if 0 in A:
    print(0)
else:
    for i in A:
        result *=i
        if result > 10**18:
            print(-1)
            break
        elif result <= 10**18:
            continue
        else:
            print(result)

Submission status: Wrong Answer

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(-1);sys.exit()
print(sum)

Submission status: Wrong Answer

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(sum);sys.exit()
print(sum)

Submission status: Wrong Answer

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(-1);sys.exit()
print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if 0 in A:
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= A[i]
    if Souseki > 1000000000000000000:
      print(-1)
      exit()
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= int(A[i])
    if Souseki > 1000000000000000000:
      print(-1)
      exit()
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= int(A[i])
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= A[i]
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  half = int(len(A)/2)
  seki1 = int(np.prod(A[:half]))
  seki2 = int(np.prod(A[half:]))
  Souseki = seki1*seki2
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  half = int(len(A)/2)
  seki1 = np.prod(A[:half])
  seki2 = np.prod(A[half:])
  Souseki = seki1*seki2
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = np.prod(A)
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = np.prod(A)
  if Souseki > np.power(10.,18).astype(np.int16):
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

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

if 0 in A:
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= A[i]
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if 0 in A:
  print(0)
else:
  Souseki = 1
  for i in range(N):
    Souseki *= A[i]
  if Souseki > 1000000000000000000:
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = np.prod(A)
  if Souseki > np.power(10.,18).astype(np.int64):
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np
np.set_printoptions(suppress=True)

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

if np.any(A==0):
  print(0)
else:
  Souseki = np.prod(A) 
  if Souseki > np.power(10.,18):
    print(-1)
  else:
    print("{:.0f}".format(Souseki))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if np.any(A==0):
  print(0)
else:
  Souseki = np.prod(A) 
  if Souseki > np.power(10.,18):
    print(-1)
  else:
    print(Souseki)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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




flag = True

if 0 in a:
  print(0)
  flag = False

if flag:
  for i in a:
    ans *= i
    if ans >= limit:
      print(-1)
      flag = False
      break

if flag:
  print(ans)

Submission status: Wrong Answer

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

ans = 1
flag = True
for i in a:
  ans *= i
  if ans >= 10**18:
    print(-1)
    flag = False
    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 a:
  ans *= i
  
if ans >= 10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    I=list(map(int,input().split()))
    num=1
    if 0 in I:
        print("0")
        return
    for i in I:
        num*=i
        if num>10*18:
            print("-1")
            return
    print()
main()

Submission status: Wrong Answer

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

s = 1
for i in range(n):
	if s <= 10**18:
		s = s*int(A[i])
	else:
		break
		
if s > 10**18:
	print(-1)
else:
	print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
num = list(map(int,input().split()))
b= 0
for a in range(len(num)):
  b = b * a
  if b > 10**18:
    print('-1')
  else:
    print(b)

Submission status: Wrong Answer

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

if nums.count(0):
    print(0)
    exit(0)
print(list(nums))

result=1
for i in nums:
    result *= i

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

Submission status: Wrong Answer

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

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

result=1
for i in nums:
    result *= i

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
X=1
while X<=10**18:
  for i in range(n):
    X*=A[i]
if X<=10**18:
  print(X)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_lis = list(input().split())

# 10^18を超えたら駄目

ans=1
rough_power=0
for i in a_lis:
    rough_power+=len(i)-1

if rough_power>18:
    print("-1")
elif "0" in a_lis:
    print(0)
else:
    for j in a_lis:
        ans=ans*int(j)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a_lis = list(input().split())

ans=1
rough_power=0
for i in a_lis:
    rough_power+=len(i)-1

if rough_power>18:
    print("-1")
elif 0 in a_lis:
    print(0)
else:
    for j in a_lis:
        ans=ans*int(j)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a_lis = list(input().split())

# 10^18を超えたら駄目

ans=1
rough_power=0
for i in a_lis:
    rough_power+=len(i)-1

if rough_power>18:
    print("-1")
else:
    for j in a_lis:
        ans=ans*int(j)

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

Submission status: Wrong Answer

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

result = 1
flag = 1

if A.count(0) == 0:
    for x in range(N):
        result = result * A[x]
        if result >= 10**18 + 1:
            print(0)
            exit()
    print(result)
else:
    print(0)

Submission status: Wrong Answer

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

result = 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while count <= N - 1:
    ans *= S[count]
    if ans <= 10**18:
        ans = -1
        break
    count += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mul_max = 10**18
N = int(input())
mul1 = 1

out_flag  =False
mul2 = map(int, input().split(" "))
for i in mul2:
    if i == 0:
        print(0)
        break
else:
    out_flag = True

if out_flag:   
    for i in mul2:
        mul1 = mul1 * i
        if mul1 > mul_max:
            print(-1)
            break
    else:
        print(mul1)

Submission status: Wrong Answer

Solution code:
mul_max = 10**18
N = int(input())
mul1 = 1

mul2 = map(int, input().split(" "))
for i in mul2:
    if i == 0:
        print(0)
        break
else:
    for i in mul2:
        mul1 = mul1 * i
        if mul1 > mul_max:
            print(-1)
            break
    else:
        print(mul1)

Submission status: Wrong Answer

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

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    
    out = 1
    for n in A:
        out = n * out
    if out >= 1000000000000000000:
        print(-1)
    else:
        print(out)



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

else:
    print(ans)

Submission status: Wrong Answer

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

result = 1
for i in range(N):
    result *= A[i]
    if result > (10**18):
        print(-1)
        break
    else:
        continue
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers =[i for i in map(int,input().split())]
result =1
standard = 10**18
for i in range(N):
  result *= numbers[i]
  if result > standard:
    print("-1")
    break
  elif result == 0:
    print("0")
    break
else:
  print(result)

Submission status: Wrong Answer

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > 10^(18):
      print(-1)
      break
  else:
    print(result)

Submission status: Wrong Answer

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > 10^(18):
      print(-1)
      break
    else:
      continue
  else:
    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]
  if result > 10^(18):
    print(-1)
    break
  else:
    continue
else:
  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]
  if result > 10^(18):
    print(-1)
    break
else:
  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]
  if result > 10^(18):
    print(-1)
    break
  
    
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]
  if result > 10^(18):
    break
  print(-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]
if result > 10^(18):
         result = -1
print(result)

Submission status: Wrong Answer

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

multi=1
for i in range(len(input)):
  multi *= input[i]
  if(multi > (10 ** 18)):
    print(-1)
    exit(0)

print(multi)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

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

s = 1
for x in a:
  s *= x
if s > 1000000000000000000:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

final = 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

final = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def b169(n, alist):

    ans = 1
    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def b169(n, alist):

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

    return ans if ans < 10**18 else -1

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = map(int, input().split(' '))
result = 1
if min(nums) == 0:
    print(0)
else:
    for i in nums:
        result *= i
    if result > 10**18:
        print(-1)
    else:
        print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
x = 1
if A.count(0) == 0:
  for i in range(N):
    y = x
    a = A[i]
    x = a*y
    if x//10**18 >= 1:
      break
    
  if x//10**18 >= 1:
    print(-1)
  else:
   print(x)
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

if 0 in A:
    ans = 0
else:
    for a in A:
        n = ans * a
        ans = n if n < 10 ** 18 else -1

print(ans)

Submission status: Wrong Answer

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

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
    elif  ans * i > 10**18:
        ans = -1
        break
    else:
        ans *= i

print(ans)

Submission status: Wrong Answer

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

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

if flag == 1:
    print(-1)
elif flag == -1:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

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

if flag == 1:
    print(-1)
elif flag == -1:
    print(0)
else:
  print(ans)

Submission status: Wrong Answer

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

if flag == 1:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

if flag == 1:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

temp = 1

if 0 in a:
    print(0)

else:
    for i in a:
        temp *= i
        if temp >= 10**18:
            print(-1)
            sys.exit()
    print(temp)

Submission status: Wrong Answer

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

temp = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main(numbers: list):
    result = 1
    for num in numbers:
        result *= num
        if result > 10 ** 18:
            print(-1)
            return

    print(result)


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

Submission status: Wrong Answer

Solution code:
MX = 10**18
def fun(a,n):
	if max(a) > MX:
		return -1
	
	res = a[0]
	for i in range(1,n):
		res = res * a[i]
		if res > MX:
			return -1
	return res

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

Submission status: Wrong Answer

Solution code:
MX = 10**18
def fun(a,n):
	res = a[0]
	for i in range(1,n):
		res = res * a[i]
		if res > MX:
			return -1
	return res

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

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res >= 1e18:
    res = -1
    break
print(res)

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())
res = 1
for a in a:
  res *= a
  if res >= 1e18:
    res = -1
    break
print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 1
if l.count(0) != 0:
  print(0)
else:
  for i in range(n):
    count *= l[i]
    if count >= 1000000000000000000:
      print("-1")
      break
  if count <= 1000000000000000000:
    print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 1
if l.count(0) != 0:
  print(0)
else:
  for i in range(n):
    count *= l[i]
  if count >= 1000000000000000000:
    print("-1")
  elif count <= 1000000000000000000:
    print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 1
for i in range(n):
  count *= l[i]

if count >= 1000000000000000000:
  print("-1")
elif count <= 1000000000000000000:
  print(count)

Submission status: Wrong Answer

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

if count <= 1000000000000000000:
  print(count)

Submission status: Wrong Answer

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

if count <= 1000000000000000000:
  print(count)

Submission status: Wrong Answer

Solution code:
ans = 1
ok = True
_n = int(input())
a = list(map(int,input().split()))
for i in a:
    ans *= i
    if ans > 1e18:
        ok = False
        break
if ok:    
    print(ans)
else :
    print(-1)

Submission status: Wrong Answer

Solution code:
ans = 1
ok = True
_n = int(input())
a = list(map(int,input().split()))
for i in a:
    ans *= i
    if ans > 1e18:
        print(-1)
        ok = False
        break
if ok:    
    print(ans)
else :
    print(-1)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 1
for num in range(N):
    ans *= A[num]
    if ans > math.pow(10, 18):
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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



for ai in A:
  if ai == 0 :
    print('0')
    exit()
	    
ans = A[0]      
for i in range(1,N):
  
  ansCp = ans
  ansCnt = 1
  while ansCp >= 10:
    ansCp /= 10
    ansCnt += 1
    
  if (ansCnt > 18) or ( ansCnt == 18 and ansCp > 0 ) :
    print("-1")
    exit()
    
  ans *= A[i]
  
      
print(str(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())

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



for ai in A:
  if ai == 0 :
    print('0')
    exit()
	    
ans = A[0]
border = 18 ** 10
      
for i in range(1,N):
  
  ansCp = ans
  ansCnt = 0
  while ansCp >= 10:
    ansCp /= 10
    ansCnt += 1
    
  if ansCnt > 18 and ansCp > 0:
    print("-1")
    exit()
    
  ans *= A[i]
  
      
print(str(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#print(a)

ans = int(a[0])
for i in range(1,N):
    if ans > 10**18:
        break
    else:
        ans = ans * int(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()))
A.sort(reverse=True)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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