Buggy python submission (verdict: Runtime Error):
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(b).log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1
    for c in a:
        ans *= c
    print(ans)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(b).log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1
    for c in a:
        ans *= c
    print(ans)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(f'{b}').log10() for b in a if a != 0]
ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1

    for c in a:
        ans *= c

    print(ans)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(f'{b}').log10() for b in a if a != 0]
ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1

    for c in a:
        ans *= c

    print(ans)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
from decimal import *

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

getcontext().prec = 28


aa = [Decimal(f'{b}').log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c

if ans > 18.0:
    print(-1)
else:
    ans = 1

    for c in a:
        ans *= c

    print(ans)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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


ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

a.sort()

ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

a.sort()

ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)


Fixed submission:
n = int(input())

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

ans = 1

for b in a:
    if b == 0:
        ans = 0
        break
    else:
        ans *= b
        if ans > pow(10, 18):
            ans = -1
            break

print(ans)