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

N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)
    if(int(val) == 0):
        print(0)
        sys.exit()

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

Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)

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

Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)
 
if(ans > 10 **18):
    print(-1)
else:
    print(ans)

Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import queue
N = int(input())

q = queue.Queue()

[q.put(int(_)) for _ in input().split()]

ans = 1
for i in range(N):
    ans = ans * q.get()

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

Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = [int(_) for _ in input().split()]

ans = 1


for i in An:
    ans = ans * i
   
if(ans > 10**18):
    print(-1)
else:
    print(ans)

Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import sys
sys.setrecursionlimit(10**7) 

N = int(input())
An = [int(_) for _ in input().split()]

ans = 1;
for i in An:
    ans = ans * i
    
if(ans > 10**18):
    print(-1)
else:
    print(ans)


Fixed submission:
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)