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

print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
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
        exit

print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1

for i in range(n):
    if(a[i] == 0):
        exit
if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
elif n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
    ans *= a[n//2]

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

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1

if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
elif n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
    ans *= a[n//2+1]

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

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1

for i in a:
    ans *= i

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

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1

import functools
import operator

result = functools.reduce(operator.mul, a)

if result > 10**18:
    result = -1

print(result)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1

if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]

if n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]

    ans *= a[n//2+1]

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

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[len(a)-i-1]
        if a[i] == 0 or a[len(a)-i-1] == 0:
            ans = 0
            exit

if n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[len(a)-i-1]
        if a[i] == 0 or a[len(a)-i-1] == 0:
            ans = 0
            exit
        
    ans *= a[len(a)//2+1]
if ans > 10**18:
    ans = -1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
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)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
if a[0] == 0:
    ans = 0
    print(ans)
    exit()

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

print(ans)