Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=1
a=list(map(int,input().split()))
m=n-a.count(1)
b=sorted(a)
c=list(set(b))
if (1 in b)and(len(c)>1):
    if c[1]==1: 
        del b[:b.index(c[2])-1]
    else:
        del b[:b.index(c[1])-1]
for i in range(n):
    ans*=b[i]
    if 0 in a:
        ans=0
        break
    if m>68:
        ans=-1
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=1
a=list(map(int,input().split()))
m=n-a.count(1)
b=sorted(a)
if 1 in b: 
    del b[:b.index(2)-1]
for i in range(n):
    ans*=b[i]
    if 0 in a:
        ans=0
        break
    if m>68:
        ans=-1
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=1
a=list(map(int,input().split()))
m=n-a.count(1)
b=sorted(a)
del b[:a.index(2)-1]
for i in range(n):
    ans*=b[i]
    if 0 in a:
        ans=0
        break
    if m>68:
        ans=-1
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
a=list(map(int,input().split()))
m=n-a.count(1)
for i in range(n):
    ans*=a[i]
    if 0 in a:
        ans=0
        break
    if m>70:
        ans=-1
        break
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
ans=0
if 0 in a:
    flag=1
if flag==0:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>1000000000000000000:
            flag=-1
            break
if flag==-1:
    print(-1)
else:
    print(ans)