Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    res = 0
    N = 0

for x in range(N) :
    res *= A[x]
    if res > 10**18
        res = -1
        break

print(res)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res *= A[x]
    if res > 10**18
        res = -1
        break

print(res)


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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10**18
        res = -1
        break

print(res)


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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+18
        res = -1
        break

print(res)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+18
        res = -1
        break

print(res)


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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
res = 1

if 0 in A :
    res = 0

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        res = -1
        break

print(res)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        res = -1
        break

print(res)


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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
res = 1

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        print(-1)
        break

print(res)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
res = 1

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

for x in range(N) :
    res = res*A[x]
    if res > 10E+17
        print(-1)
        break

print(res)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
res = 1

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

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

print(res)


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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a_str = input()
a = a_str.split(' ')
total = 1

for i in a:
    total *= int(i)

if total <= 1e+18:
    print (total)
else:
    print('-1')

Fixed submission:
def total_power(n, a):
    half_total = []
    start = 0
    end = len(a)
    if n%2 == 0:
        start = 0
    else:
        start = 1 
        half_total.append(a[0])

    for i in range(start, end, 2):
        half_total.append(a[i]*a[i+1])
    if len(half_total) == 1:
        return half_total[0]
    else:
        return total_power(len(half_total), half_total)


n = int(input())

a_str = input()
a_strs = a_str.split(' ')
a = [int(s) for s in a_strs]
total = total_power(n, a)

if total <= 1e+18:
    print (total)
else:
    print('-1')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a_str = input()
a = a_str.split(' ')
total = 1

for i in a:
    total *= int(i)

if total <= 1e+18:
    print (total)
else:
    print('-1')

Fixed submission:
def total_power(n, a):
    half_total = []
    start = 0
    end = len(a)
    if n%2 == 0:
        start = 0
    else:
        start = 1 
        half_total.append(a[0])

    for i in range(start, end, 2):
        half_total.append(a[i]*a[i+1])
    if len(half_total) == 1:
        return half_total[0]
    else:
        return total_power(len(half_total), half_total)


n = int(input())

a_str = input()
a_strs = a_str.split(' ')
a = [int(s) for s in a_strs]
total = total_power(n, a)

if total <= 1e+18:
    print (total)
else:
    print('-1')