Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort()
res = 1
# over_count=0
for i in range(N):
    res *= A[i]
if res > (10 ** 18):
    print(-1)
    exit()
print(res)


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

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
N = int(input())
A = list(map(str, input().split()))
res = 1
for i in range(N):
    res = Decimal(str(res)) * Decimal(A[i])
if res > (10 ** 18):
    print(-1)
    exit()
print(res)


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

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
N = int(input())
A = list(map(str, input().split()))
res = 1
for i in range(N):
    res = Decimal(str(res)) * Decimal(A[i])
if res > (10 ** 18):
    print(-1)
    exit()
print(res)


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

Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
N = int(input())
A = list(map(str, input().split()))
res = 1
for i in range(N):
    res = Decimal(str(res)) * Decimal(A[i])
if res > (10 ** 18):
    print(-1)
    exit()
print(res)


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

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int, input().split()))
res = prod(a)
if res > (10**18):
    print(-1)
    exit()
print(res)


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

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

func = functools.partial(functools.reduce, operator.mul)

n = int(input())
a = list(map(int, input().split()))
res = func(a)
if res > (10**18):
    print(-1)
else:
    print(res)


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= a[i]
if res > (10**18):
    print(-1)
else:
    print(res)


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

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
res = np.prod(a)
if res > (10**18):
    print(-1)
else:
    print(res)


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= a[i]
if res > (10**18):
    print(-1)
else:
    print(res)


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= a[i]
if res > (10**18):
    print(-1)
else:
    print(res)


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