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

x = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        x *= a[i]
    
    if x > 1000000000000000000:
        print(-1)
    else:
        print(x)


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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

x = 1
for i in range(n):
    x *= a[i]    
    
if x > 1000000000000000000:
    if 0 in a:
        print(0)
    else:
        print(-1)
else:
    print(x)


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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

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


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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


import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
x = prod(map(int, input().split()))

if x > 1000000000000000000:
    print(-1)
else:
    print(x)


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
x = prod(a)

if x > 1000000000000000000:
    print(-1)
else:
    print(x)


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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

x = 1
for i in range(n):
    x *= a[i]
    
if x > 1000000000000000000:
    print(-1)
else:
    print(x)


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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)

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

x = 1
for i in a:
    x *= i
    
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

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

x = 1
flag = False
INF = 10**18
if 0 in a:
    print(0)
else:
    for i in range(n):
        if flag == False:
            x *= a[i]
        if x > INF:
            flag = True
    
    if flag:
        print(-1)
    else:
        print(x)