TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
allnum = int(input())

list = input().split()

list_i = [int(s) for s in list]

result = 0

if 0 in list_i:
  	print(0)
else:
    for n in list_i:
        result = result * n
        if result > 1000000000000000000:
            result = -1
            break
    print(result)

n = int(input())
ary = list(input().split())

if "0" in ary:
    print(0)
else:
    length = sum(map(len,ary))
    print(length-n)
    if length-n > 18:
        print(-1)
    else:
        multiple = 1
        while ary:
            multiple *= int(ary.pop())
        if multiple > 10**18:
            print(-1)
        else:
            print(multiple)


n = input()
ary = list(input().split())

if "0" in ary:
    print(0)
else:
    length = sum(map(len,ary))
    if length > 18:
        print(-1)
    else:
        multiple = 1
        while ary:
            multiple *= int(ary.pop())
        print(multiple)


n = int(input())
ary = list(map(int,input().split()))
import cmath
if 0 in ary:
    print(0)
else:
    multiple = 1
    while ary:
        multiple *= ary.pop()
        if multiple > 10**18:
            multiple = -1
            break
    print(multiple)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a=1
n=input()

s=input()
for i in range(len(s)):
  if i%2==1:
    continue
  a*=int(s[i])
if a>10**18:
  print(-1)
else:
  print(a)

a=1
n=input()

s=input()
count=""
#print(len(s))
for i in range(len(s)):
  #print(i,s[i],count)
  if a==0:
    print(0)
    break
  if s[i]==" ":
    a*=int(count)
    count=""
    continue
  elif i==len(s)-1:
    if len(count)==0:
      a*=int(s[i])
    else:
      count+=s[i]
      #print("--------")
      a*=int(count)
  else:
    count+=s[i]
  if a>10**18:
    print(-1)
    break
if a<10**18 and a!=0:
  print(a)

import sys

#1
#a,b=map(int,input().split())
#print(a*b)

#2
n=input()
s=list(map(int,input().split())) 
count=0

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

print(a)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = map(int, input().split())

ans = 1

import sys

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

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

print(ans)
  

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

ans = 1

import sys

if 0 in A:
  print(0)
  sys.exit()
  
for a in A:
  ans *= a
  if ans > pow(10, 18):
      print(-1)
      sys.exit()

print(ans)
  

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

ans = 1

import sys

if 0 in A:
  print(0)
  sys.exit()
  
for a in A:
  ans *= a
  if ans > pow(10, 18):
      print(-1)
      sys.exit()

print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10**18:
            result = -1
            break

print(result)

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

print(result)


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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10**18:
            result = -1
            break

print(result)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

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

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))

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


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

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


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

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


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

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())

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


def solve(nums):
  if any(not n for n in nums):
      return 0

  print(list(nums))
  i = 1
  for n in nums:
      i *= n
      if i > 10 ** 18:
        return -1
  return i

print(solve(nums))


n = int(input())

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


def solve(nums):
  if any(not n for n in nums):
      return 0

  i = 1
  for n in nums:
      i *= n
      if i > 10 ** 18:
        return -1
  return i

print(solve(nums))


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())

P = int(input())

out_range = 10**18

for i in range(N-1):
    tmp = int(input())
    if  P > out_range or tmp > out_range:
        print(-1)
    P = tmp * P

print(P)


N = int(input())

P = int(input())

out_range = 10**18

for i in range(N-1):
    tmp = int(input())
    if  P > out_range or tmp > out_range:
        print(-1)
        exit()
    if tmp == 0:
        print(0)
        exit()
    P = tmp * P

print(P)


N = int(input())

P = int(input())

out_range = 10**18
for i in range(N-1):    
    tmp = int(input())
    if  P > out_range || tmp > out_range:
        print(-1)
    P = tmp * P

print(P)


N = int(input())

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

out_range = 10**18

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

for i in range(N):
    tmp = P[i]
    ans *= tmp
    if  ans > out_range:
        print(-1)
        exit()

print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys

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

ans = 1

for a in A:
    if a == 0:
        print(0)
        sys.exit()

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)


import sys

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

ans = 1

for a in A:
    if a == 0:
        print(0)
        sys.exit()

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
p = 1
if a.count(0):
    print(0)
    exit(0)
for i in range(n):
    p *= a[i]
    print(p, end=' ')
    if p > int(1E18):
        print(-1)
        exit(0)
print(p)

n = int(input())
a = list(map(int, input().split()))
p = 1
if a.count(0):
    print(0)
    exit(0)
for i in range(n):
    p *= a[i]
    if p > int(1E18):
        print(-1)
        exit(0)
print(p)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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
  elif i==n-1:
    print(ans)

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

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

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

N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

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

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

answer = 1
i = 0
while len(str(answer-1))<=18 and i<N: 
    answer *= int(A_list[i])
    i+=1

if i==N-1:
    print(answer)
else:
    print(-1)

import math
N = int(input())
A_list = list(map(int,input().split()))
#print(A_list)

answer = 1
i_0 = 0.
for a in A_list:
    if a == 0:
        answer=0
        i_0=0.
        break
    else:
        answer *= a
        i_0 += math.log10(float(a))

if i_0>=18:
    print(-1)
else:
    print(answer)

import math
N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

if math.log10(answer) > 18:
    print("-1")
else:
    print(answer)


import math
N = int(input())
A_list = list(map(int,input().split()))
answer = 0.
for a in A_list:
    if a!=0.:
        answer+=math.log10(a)
    else:
        answer=0.
        break
    #print(answer)

if answer > 18.:
    print(-1)
else:
    print(answer)


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

if A_list[0]==0:
    answer = 0
else:      
    answer = 1
    for a in A_list:
        answer *= a
        if len(str(answer-1)) > 18:
            answer = -1
            break
print(answer)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys
n=int(input())
a=input()
a0=a.split()
l=list()
b=1
q= "0" in a0
if q==True:
    print(0)
    sys.exit()
for i in range (n):
    a1=int(a0[i])
    b=b*a1
    if b>10**18:
        print(-1)
        sys.exit()

import sys
n=int(input())
a=input()
a0=a.split()
l=list()
b=1
q= "0" in a0
if q==True:
    print(0)
    sys.exit()
for i in range (n):
    a1=int(a0[i])
    b=b*a1
    if b>10**18:
        print(-1)
        sys.exit()
print(b)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def solve(n, a):
    for x in a:
        if x == 0:
            return 0
    ans = 1
    for x in a:
        ans *= x
        if ans >= 10**18:
            return -1
    return ans
    
n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)


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

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

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
l = list(map(int, input().split()))
res = 1
for x in l:
  res *= x
if res > 10**18:
  res = -1
print(res)

input()
l = list(map(int, input().split()))
l.sort()
res = 1
for x in l:
  res *= x
  if res > 10**18:
    print(-1)
    exit(0)
print(res)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
numa, numb = input().strip().split()
numa, numb = [int(numa), float(numb)]

numb *= 100
numb = int(numb)
ans = int((numa*numb)/100)
print(ans)

numa, numb = input().strip().split()
numa, numb = [int(numa), float(numb)]

numb *= 100
numb = int(numb)
ans = int((numa*numb)/100)
print(ans)

import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

if ans <= overflow:
    print(ans)
else:
    print(-1)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
number = list(map(int, input().split()))
seki = 0
seki2 = -1
for i in numebr:
  seki = seki*i
 if seki > 10 ** 18:
  print(seki2)
 else:
  print(seki)

n = int(input())
number = list(map(int, input().split()))
seki = 0
seki2 = -1
for i in number:
  seki = seki*i
if seki > 10 ** 18:
  print(seki2)
else:
  print(seki)

n = int(input())
number = list(map(int, input().split()))
seki = 0
seki2 = -1
for i in number:
  seki = seki*i
 if seki > 10 ** 18:
  print(seki2)
 else:
  print(seki)

n = int(input())
number = list(map(int, input().split()))
seki = 1
if 0 in number:
  seki = 0
else:
  for i in number:
    seki = seki*i
    if seki > 10 ** 18:
      seki = -1
      break
    else:
      continue
print(seki)
  


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)

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)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a=int(input())
b=input.split(' ')
m=0
s=0
while m<a:
    s=s+int(b[m])
    m=m+1
if s<10**18:
    print(-1)
else:
    print(s)


a=int(input())
b=input().split(' ')
m=0
s=1
j=0
while m<a:
	if b[m]==0:
        print(0)
        j=j+1

    m=m+1

m=0
while m<a and j==0:
    s=s*int(b[m])
    if s>10**18:
		print(-1)

    m=m+1


else:
    print(s)

a=int(input())
b=input().split(' ')
m=0
s=1
i=0
o=0
while i<a:
    if int(b[i])==0:
        print(0)
        o=o+1
    i=i+1
while m<a and o==1:
    s=s*int(b[m])
    m=m+1
    if s>10**18 and o==0:
        print(-1)
        o=o+1
        break

if o==0:
    print(s)


a=int(input())
b=input().split(' ')
m=0
s=1
j=0
while m<a:
	if b[m]==0:
      print(0)
      j=j+1
    
    m=m+1

m=0
while m<a and j==0:
    s=s*int(b[m])
    if s>10**18:
		print(-1)
    
    m=m+1


else:
    print(s)

a=int(input())
b=input.split()
m=0
s=0
while m<a:
    s=s+int(b[m])
    m=m+1
if s<10**18:
    print(-1)
else:
    print(s)


a=int(input())
b=input().split(' ')
m=0
s=1
i=0
o=0
while i<a:
    if int(b[i])==0:
        print(0)
        o=o+1
    i=i+1
while m<a and o==0:
    s=s*int(b[m])
    m=m+1
    if s>10**18 and o==0:
        print(-1)
        o=o+1
        break

if o==0:
    print(s)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
arr = []

z=False
for x in input().split(' '):
    if x == 0:
        z = True
    arr.append(x)
if z == True:
    print(0)

else:
    ans = 1
    for x in arr:
        ans *= x
        if ans > int(1e18):
            print(-1)
    else:
        print(ans)

n = int(input())
arr = []

z=False
for x in input().split(' '):
    if x == '0':
        z = True
    arr.append(int(x))
if z == True:
    print(0)

else:
    ans = 1
    for x in arr:
        ans *= x
        if ans > int(1e18):
            print(-1)
            exit(0)
    
    print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
r = list(map(int,input().split()))

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x >= 10**18:
        x = -1
        break

print(x)

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

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x >= 10**18:
        x = -1
        break

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

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

lim = int(10^18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x >= lim*10:
        x = -1
        break

if x > lim:
        x = -1

print(int(x))

import math
n = int(input())
r = list(map(int,input().split()))

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]

    if x > 1000000000000000000:
        break

if x > 1000000000000000000:
    x = -1

if 0 in r:
    x = 0

print(math.floor(x))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)

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)

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)

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

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

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18 + 1
total = 1
if A.index(0):
    print(0)
else:
    for i in A:
        total *= i
    if total > over_value:
        total = -1
    print(total)

N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18
total = 1
cnt = 0
while cnt < N:
    total *= A[cnt]
    if total > over_value:
        total = -1
        break
    cnt += 1
    
for i in range(N):
    if A[i] == 0:
        total = 0
print(total)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())

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

ans = 1

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

n = int(input())

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

ans = 1

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = map(int, input().split())
num = 1
for i in a:
  num = num*i
  if num >= 10**18:
    print(-1)
    exit()
  elif num == 0:
    print(0)
    exit()
print(num)

N = int(input())
a = map(int, input().split())
if 0 in a:
  print(0)
  exit()
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)

N = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
  print(0)
  exit()
num = 1
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
  N = int(input())
  A = list(map(int,input()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 10**18:
      print(-1)
      return
    
    print(prod)

main()

def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main ()


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
data=list(map(int,input().split()))
s=1
for d in data:
    if data == 0:
        print(0)
        break
else:
    for d in data:
        s *= d
        if s > 10**18:
            print(-1)
        else:
            print(s)

data=list(map(int,input().split()))
s=1
if 0 in data:
    print(0)
else:
    for f in data:
        s *= f
    if s > 10**18:
        print(-1)
    else:
        print(s)

N=int(input())
data=list(map(int,input().split()))
s=1
for 0 in data:
    print(0)
    end()
for d in data:
    s *= d
if s > 10**18:
    print(-1)
else:
    print(s)
    

N=int(input())
data=list(map(int,input().split()))
s=1
for d in data:
    if d == 0:
        print(0)
        break
else:
    for d in data:
        s *= d
        if s > 10**18:
            print(-1)
        else:
            print(s)

N=int(input())
data=list(map(int,input().split()))
if 0 in data:
    print(0)
else:
    s=1
    for f in data:
        s *= f
        if s > 10**18:
            break
    if s > 10**18:
        print(-1)
    else:
        print(s)
    

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N, A = map(int, open(0).read().split())
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        break
else:
    print(ans)


N, *A = map(int, open(0).read().split())
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        break
else:
    print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def test():
  n=int(input())
  A=list(map(int,input().split()))
  if (0 in A):
    print("0")
    return
  a=1
  for i in range(n):
   a*=A[i]
   if a > 10**18:
     print("-1")
     return
   else:
     print(a)
test()

def test():
  n=int(input())
  A=list(map(int,input().split()))
  a=1

  if (0 in A):
    print("0")
    return

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a=int(input())
li = list(map(int,input().split()))

n=1
for i in  list
    n*=n*list[i]

if(n>1000000000000000000):
    print("-1")
else:
    print(n)


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

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

if(n>1000000000000000000):
    print("-1")
else:
    print(n)


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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
    print(0)
else:
    ans = 1
    for i in A:
        if ans > 1000000000000000000:
            print(-1)
    print(ans)

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

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

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



Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
keta=1
for i in A:
    keta*=i
    if keta>1000000000000000000:
        print(-1)

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
keta=1
for i in A:
    keta*=i
    if keta>1000000000000000000:
        print(-1)
    else:
        print(keta)

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print("0")
keta=1
for i in A:
    keta*=i
    if keta>1000000000000000000:
        print("-1")
    

N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    keta=1
    for i in A:
        keta*=i
        if keta>1000000000000000000:
            break
        
    if keta>1000000000000000000:
        print(-1)
    else:  
        print(keta)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()


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

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())

print(N)

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

ans=1
lim=10**18
flg=0

for i in nl:
  ans=ans*i
  if ans>lim:
    flg=-1
    break
    
if flg==0:
  print(ans)
else:
  print(-1)


N = int(input())

print(N)

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

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

lim = 10**18

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


def main():
  N = int(input())
  nl = list(map(int,input().split()))

  if 0 in nl:
    print(0)
    return

  ans=1
  lim=10**18

  for i in nl:
    ans *= i
    if ans>lim:
      print(-1)
      return
    
  print(ans)
  
main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
        x = 1
    else:
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
        x = 1
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)


def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        	if x > 10**18:
            	print(-1)
                exit()
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)


from math import log10

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        if log10(x) >= 18:
            print(-1)
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)

from math import log10

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        	if x > 10**18:
            	print(-1)
                exit()
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)


from math import log10
import numpy as np

def main(N):
    ans = np.prod(np.array(list(map(int, input().split()))))
    if log10(ans) >= 18:
        print(-1)
    else:
        print(ans)





if __name__ == '__main__':
    N = int(input())
    main(N)

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
if int(count) == 0:
  result = 0
else:
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))
 
    result = 1

  else:
    for intn in nums_int:
      result *= intn
      if result > 10**18:
        result = -1
        break
    
print(result)

count = input()
nums_str = input().split()
nums_int = []
for strn in nums_str:
  nums_int.append(int(strn))

result = 1
if count == 0:
  result = 0
elif:
  for intn in nums_int:
    result *= intn
    if result > 10**18:
      result = -1
      break
    
print(result)

def process():
  count = int(input())
  if count == 0:
    result = 0
  else:
    nums_str = input().split()
    nums_int = []
    for strn in nums_str:
      nums_int.append(int(strn))

      if 0 in nums_int:
        result = 0
        return result
      else:
        result = 1
        for intn in nums_int:
          result *= intn
          if result > 1000000000000000000:
            result = -1
            return result
    
print(process())

def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 10**18:
        result = -1
        return result
    return result
    
print(process())

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
ans=1
n=int(input())
lim=10**18
for i in list(map(int,input().split())):
    ans*=i
print(ans if ans>lim else -1)

ans=1
n=int(input())
lim=10**18
l=list(map(int,input().split()))
if 0 in set(l):print(0);exit()
for i in l:
    ans*=i
    if ans>lim:print(-1);exit()
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input().split()[0])
a_list = list(map(int, input().split()))
t = 1
for a in a_list:
    t *= a
    if t >= 10**18:
        t = -1
        break
print(t)


N = int(input().split()[0])
a_list = list(map(int, input().split()))
t = 1
if 0 in a_list:
    t = 0
else:
    for a in a_list:
    	t *= a
    	if t > 10**18:
        	t = -1
        	break
print(t)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys

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

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

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

print(result)

import sys

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

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

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

print(result)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
    break
else:
    print(count)

n = int(input())

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
    break
else:
    print(count)

n = int(input())

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

count = 1

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

else:
    print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
I = list(map(int, input().split()))
ans = 1

kMax = 10**18

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

for i in map(int, input().split()):
    ans *= i
    if ans > kMax:
        print(-1)
        exit()
print(ans)



N = int(input())
I = list(map(int, input().split()))
ans = 1

kMax = 10**18

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

for i in I:
    ans *= i
    if ans > kMax:
        print(-1)
        exit()
print(ans)



Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np

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

ans = np.prod(A)
if ans > 10**8:
    ans = -1

print(ans)

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

A.sort()
ans = 1

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a=int(input())
b=input().split(" ")
sum1=1

for i in range(a):
	sum1=sum1*int(b[i])

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

a=int(input())
b=input().split(" ")
sum1=1

if "0" in b:
	print("0")
else:
	for i in range(a):
		sum1=sum1*int(b[i])
		if sum1>10**18:
			sum1=-1
			break
	print(sum1)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())

MAX_NUM = 10 ** 18

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

for num in nums:
  if num == 0:
    print(0)
    exit()

ans = 1

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

print(ans)


n = int(input())

MAX_NUM = 10 ** 18

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

for num in nums:
  if num == 0:
    print(0)
    exit()

ans = 1

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

print(int(ans))


n = int(input())

MAX_NUM = 10 ** 18

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

for num in nums:
  if num == 0:
    print(0)
    exit()

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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
    if ans>1000000000000000000:
    ans=-1
    break
if 0 in lis:
    ans=0
else:
    print(ans)


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

n=int(input())
lis=list(map(int,input().split()))
ans=1
for i in lis:
    ans*=i
    if ans>1000000000000000000:
        ans=-1
        break
if 0 in lis:
    ans=0

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
data = list(map(int, input().split()))
data.sort()
data.reverse()
 
ans = 1

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

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

ans = 1

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

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

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

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if sum > upper && flag != 0:
    flag = 2
  if num == 0:
    flag = 0
if flag == 2:
  print(-1)
else:
  print(sum * flag)

n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  if flag == 1:
    sum = sum * num
    if sum > upper:
      flag = 2
  if num == 0:
    flag = 0
    break
if flag == 2:
  print(-1)
else:
  print(sum * flag)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
n_l = list(map(int, input().split()))
print(n_l)

VORDER = 10 ** 18
ans = n_l[0]

for i in range(1, n):
    if 0 in n_l:
        ans = 0
        break
    ans = n_l[i] * ans
    if ans > VORDER:
        ans = -1
        break

print(ans)

def check() -> int:
    n = int(input())
    n_l = list(map(int, input().split()))
    VORDER = 10 ** 18
    ans = 1
    
    if 0 in n_l:
        ans = 0
        break
    else:
        for i in n_l:
            ans = i * ans
            if  ans > VORDER:
                ans = -1
                break
    return ans
if __name__ == '__main__':
    print(check())


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

VORDER = 10 ** 18
ans = 1

if 0 in n_l:
    ans = 0
else:
    for i in n_l:
        ans = i * ans
        if ans > VORDER:
            ans = -1
            break

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
line = input().split()

MAX = 1
for i in range(18):
    MAX = MAX * 10

ans = 1

for l in line:
    ans = int(l) * ans

if ans < MAX:
    print(ans)
else:
    print(-1)


N = int(input())
line = input().split()

MAX = 1000000000000000000

ans = 1

if not '0' in line:
    for l in line:
        if l == 0:
            ans = 0
            break
        if not ans > MAX:
            ans = int(l) * ans

else:
    ans = 0


if ans <= MAX:
    print(ans)
else:
    print(-1)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**8:
    ans = -1
    break
print(ans)

import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))]
if 0 not in a:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
        print("-1")
        exit()
    print(ans)
else:
    print("0")

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

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*a[i]
if len(ans)>19:
    print("-1")
    exit()
print(ans)

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    if ans<=10**18:
        ans*=a[i]
    elif ans>10**18
        print("-1")
        exit()
print(ans)

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

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

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

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    if ans<=10**18:
        ans*=a[i]
    elif ans>10**18
        print("-1")
print(ans)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import math
N = int(input())
A = [int(_) for _ in input().split()]

print(A)
ans = A[0]

for i in range(1, N):
    ans *= A[i]

if ans != 0:
    ans_size = int(math.log10(ans) + 1)
else:
    ans_size = 1

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


import math
N = int(input())
A = [int(_) for _ in input().split()]

ans = A[0]
isOver = False

if 0 in A:
    print(0)
else:
    for i in range(1, N):
        ans *= A[i]
        ans_size = int(math.log10(ans) + 1)
        if ans_size >= 19 and ans - (10**18) >= 1:
            isOver = True
            break

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


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
p = 1
for i in range(N):
    p = p*A[i]
    if p >=10**18:
        p = -1
print(p)

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

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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted