Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if n==1:
        if sort_p[0]!=0:
            print(x)
        else:
            print(x-1)
    else:
        num=0
        if sort_p[0]!=0:
            print(x)
        else:
            for i in range(1,n):
                if i%2!=0:
                    num+=1
                if sort_p[i]!=num:
                    ans=num
                    break
            small=x-ans
            big=x+ans
            if (small not in p)&(big not in p):
                print(small)
            elif small in p:
                print(big)
            elif big in p:
                print(small)

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

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if n==1:
        if sort_p[0]!=0:
            print(x)
        else:
            print(x-1)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        small=x-ans
        big=x+ans
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)




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

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)

Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
p=list(map(int,input().split()))

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if sort_p[0]!=0:
        print(x)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        #print(ans)
        small=x-ans
        big=x+ans
        #print(p)
        #print(small,big)
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)




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

if n==0:
    print(x)
    exit()

for i in range(n):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
print(x-n)
Buggy python submission (verdict: Runtime Error):
from collections import deque

n,m=map(int,input().split())
graph=[[] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)#aにはbがつながってる
    graph[b-1].append(a-1)#bにはaがつながってる
#print(graph)

res=[-1]*n
que=deque()
que.append(0)

while len(que)>0:
    i=que.popleft();
    for j in graph[i]:
        if res[j]==-1:
            res[j]=i
            que.append(j)
    #print(que)

print("Yes")
for l in res[1:]:
    print(l+1)

Fixed submission:
n=input()
if n[-1]=="3":
    print("bon")
elif (n[-1]=="0")|(n[-1]=="1")|(n[-1]=="6")|(n[-1]=="8"):
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.insert(0,0)
#print(a)
count=[0,a[1]]
#print(count)
for i in range(2,k+1):
    if a[count[i-1]] in count:
        count.append(a[count[i-1]])
        break
    count.append(a[count[i-1]])
count.pop(0)
#print(count)
f=count.index(count[-1])
d=len(count)-1-f
#print(f,d)
k-=f
k%=d
#print(k)
#print(count[f+k])
if k!=0:
    print(count[f+k-1])
else:
    print(count[f+d-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
visited={}
for i in range(1,n+1):
    visited[i]=-1
l=[1]
visited[1]=0
i=1
while True:
    if visited[a[l[i-1]-1]]==0:
        roop_start=l.index(a[l[i-1]-1])
        break
    visited[a[l[i-1]-1]]=0
    l.append(a[l[i-1]-1])
    i+=1
roop_dif=i-roop_start

if k<roop_start:
    print(l[k])
else:
    k-=roop_start
    k%=roop_dif
    print(l[roop_start+k])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
    for j in range(i+1,n):
        if abs(i-j)==a[i]+a[j]:
            sum+=1
print(sum)

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

add=[]
sub=[]
for i in range(n):
    add.append(i+a[i])
    sub.append(i-a[i])

add_dic={}
sub_dic={}

for l in add:
    if l in add_dic:
        add_dic[l]+=1
    else:
        add_dic[l]=1

for l in sub:
    if l in sub_dic:
        sub_dic[l]+=1
    else:
        sub_dic[l]=1

ans=0

for i,k in add_dic.items():
    if i in sub_dic:
        ans+=k*sub_dic[i]

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

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    while b*i-1<=n:
        j=b*i-1
        num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
        i+=1
print(num)


Fixed submission:
import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    j=b-1
    num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
print(num)

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

a,b,n=map(int,input().split())
num=-100
for x in range(1,n+1):
    num=max(num,math.floor(a*x/b)-a*math.floor(x/b))
print(num)



Fixed submission:
import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    j=b-1
    num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a_list=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[i]=a_list.count(i+1)
for l in ans:
    print(l)

Fixed submission:
import collections
n=int(input())
a_list=list(map(int,input().split()))
ans=[0]*n
c = collections.Counter(a_list)
#print(c)
for i in range(n-1):
    print(c[i+1])
print("0")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a_list=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1):
    ans[i]=a_list.count(i+1)
for l in ans:
    print(l)

Fixed submission:
import collections
n=int(input())
a_list=list(map(int,input().split()))
ans=[0]*n
c = collections.Counter(a_list)
#print(c)
for i in range(n-1):
    print(c[i+1])
print("0")
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
sum = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += gcd(a, b, c)

print(sum)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
sum = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += gcd(a, b, c)

print(sum)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[0]*m
c=[0]*m
for i in range(m):
    s[i],c[i]=map(int, input().split())

for num in range(1000):
    if len(str(num))==n:
        #print(num)
        digit=[0,str(num)[0],str(num)[1],str(num)[2]]
        digit[1]=int(digit[1])
        digit[2]=int(digit[2])
        digit[3]=int(digit[3])
        flag=0
        #print(100*int(digit[1])+10*int(digit[2])+int(digit[3]))
        #print(digit)
        for i in range(m):
            if digit[s[i]]==c[i]:
                flag+=1
        if flag==m:
            print(100*digit[1]+10*digit[2]+digit[3])
            exit()
print("-1")


Fixed submission:
#https://atcoder.jp/contests/abc157/tasks/abc157_c
n,m=map(int,input().split())
s=[0]*m
c=[0]*m
for i in range(m):
    s[i],c[i]=map(int, input().split())

for num in range(1000):
    if len(str(num))==n:
        digit=[0]*n
        l=n
        k=num
        while l>0:
            digit[l-1]=k%10
            k=k//10
            l-=1
        flag=0
        for j in range(m):
            if digit[s[j]-1]==c[j]:
                flag+=1
        if flag==m:
            print(num)
            exit()
print("-1")
Buggy python submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc154/tasks/abc154_c

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

for i in range(n-1):
    if a[i]==a[i+1]:
        print("NO")
        exit()

print("YES")

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()

if s==u:
    print(a-1,b)
else:
    print(a,b-1)
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc154/tasks/abc154_c

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

for i in range(n):
    for j in range(n):
        if j<=i:
            continue
        if a[i]==a[j]:
            print("NO")
            exit()

print("YES")

Fixed submission:
#https://atcoder.jp/contests/abc154/tasks/abc154_c

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

for i in range(n-1):
    if a[i]==a[i+1]:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc153/tasks/abc153_c

n,k=map(int,input().split())
h=list(map(int,input().split()))
for _ in range(k):
    h[h.index(max(h))]=0
sum=0
for l in h:
    sum+=l
print(sum)

Fixed submission:
#https://atcoder.jp/contests/abc153/tasks/abc153_c

n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
sum=0
for i in range(n-k):
    sum+=h[i]
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc152/tasks/abc152_c

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n):
    flag=1
    for j in range(i):
        if p[i]>p[j]:
            flag=0
            break
    if flag==1:
        count+=1
print(count)


Fixed submission:
#https://atcoder.jp/contests/abc152/tasks/abc152_c

n=int(input())
p=list(map(int,input().split()))
count=1
min_num=p[0]
for i in range(1,n):
    min_num=min(p[i-1],min_num)
    if p[i]<=min_num:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

a,b=map(int,input().split())
ans=lcm(a,b)
print(ans)

Fixed submission:
import fractions

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b=map(int,input().split())
ans=lcm(a,b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/abc098/tasks/arc098_a
n=int(input())
s=input()

ans=100000000000
for i in range(n):
    count=0
    for j in range(n):
        if i==j:
            continue

        if (i<j)&(s[j]=="E"):
            count+=1
        elif (j<i)&(s[j]=="W"):
            count+=1

    ans=min(ans,count)

print(ans)


Fixed submission:
#https://atcoder.jp/contests/abc098/tasks/arc098_a
n=int(input())
s=input()

"""ans=100000000000
for i in range(n):
    count=0
    for j in range(n):
        if i==j:
            continue

        if (i<j)&(s[j]=="E"):
            count+=1
        elif (j<i)&(s[j]=="W"):
            count+=1

    ans=min(ans,count)

print(ans)"""#O(N^2)

count_W=[]
for i in range(n):
    count_W.append(0)

if s[0]=="W":
    count_W[0]=1
else:
    count_W[0]=0

for i in range(1,n):
    if s[i]=="W":
        count_W[i]=count_W[i-1]+1
    else:
        count_W[i]=count_W[i-1]

for i in range(n):
    if i==0:
        ans=(n-1)-(count_W[n-1]-count_W[0])
    else:
        ans=min(ans,count_W[i-1]+(n-1-i)-(count_W[n-1]-count_W[i]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i
str = str.replace("resare","")
str = str.replace("esare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
if len(str)==0:
    print("YES")
else:
    print("NO")


Fixed submission:
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i
str = str.replace("resare","")
str = str.replace("esare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
if len(str)==0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i

#str_list = ["maerd", "remaerd", "esare", "resare"]
str = str.replace("resare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
str = str.replace("esare","")

"""while True:
    flag=0
    for l in str_list:
        if str.startswith(l):
            print("str:{},l:{}".format(str,l))
            str=str.lstrip(l)
            #ここで想定よりも１文字多く削除されてしまう(erasedream)
            print("str:{},l:{}".format(str,l))
            flag+=1
    if flag==0:
        break"""

if str == "":
    print("YES")
else:
    print("NO")

Fixed submission:
s = list(input())
s.reverse()
str = ""
for i in s:
    str+=i
str = str.replace("resare","")
str = str.replace("esare","")
str = str.replace("remaerd","")
str = str.replace("maerd","")
if len(str)==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
numa, numb = input().strip().split()
numa, numb = [int(numa), float(numb)]

numb *= 100
numb = int(numb)
ans = int((numa*numb)/100)
print(ans)

Fixed submission:
import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

if ans <= overflow:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
numa, numb = input().strip().split()
numa, numb = [int(numa), float(numb)]

numb *= 100
numb = int(numb)
ans = int((numa*numb)/100)
print(ans)

Fixed submission:
import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

if ans <= overflow:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
num  = int(input())
#prime number counter
ans = 0
prime_check = [1]*1000100
count = 2
while num>1:
    if prime_check[count]==1: #countが素数だった場合
        tmp = 0
        while num % count == 0: #numの因数にcountが何個含まれているか
            num/= count
            tmp += 1
        tmp2 =1
        while tmp>=tmp2: #ansに加える
            ans += 1
            tmp -= tmp2
            tmp2 += 1
        tmp = count
        while tmp*count<=1e6:
            prime_check[tmp*count] = 0
            tmp += 1
    count += 1

print(ans)

Fixed submission:
num  = int(input())
#prime number counter
ans = 0
prime_check = [1]*1000100
count = 2
while num>1:
    if prime_check[count]==1: #countが素数だった場合
        tmp = 0
        while num % count == 0: #numの因数にcountが何個含まれているか
            num/= count
            tmp += 1
        tmp2 =1
        while tmp>=tmp2: #ansに加える
            ans += 1
            tmp -= tmp2
            tmp2 += 1
        tmp = count
        while tmp*count<=1e6:
            prime_check[tmp*count] = 0
            tmp += 1
    count += 1
    if(count>1e6):
        num = 0
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int,input().split()))
a1 = 1
a2 = 1

for i in range(n):
    if i < k:
        a1 = a1*a[i]
    else:
        a2 = a1
        a1 = a[i]*a1//a[i-k]
        if a1 > a2:
            print('Yes')
        else:
            print('No')


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

for i in range(n):
    if i < k:
        continue
    else:
        if a[i-k] < a[i]:
            print('Yes')
        else:
            print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
a = list(map(int,input().split()))
m = 1000
ans = 1000
ans_list=[]

q = deque([[1000, 0, n, 0]])

while len(q) != 0:
    tmp = q.popleft()
    m,k,d,i = tmp[0],tmp[1],tmp[2],tmp[3]
    if d == 0 and m > ans:
        ans = m
        ans_list.append(m)
    elif d > 1:
        x = m//a[i]
        q.append([m-(x*a[i]),x+k,d-1,i+1])
        q.append([m+(k*a[i]),0,d-1,i+1])
        q.append([m,k,d-1,i+1])
    elif d == 1:
        q.append([m+(k*a[i]),0,d-1,i+1])

print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
k = 0
ans = 1000

for i in range(n-1):
    if a[i] < a[i+1]:
        k = ans//a[i]
        ans -= a[i]*k
        ans += a[i+1]*k

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

n = int(input())

for i in range(1, n+1):
    ans = 0
    for j in range(1, int(math.sqrt(i))):
        for k in range(1, int(math.sqrt(i))):
            temp = i-(3*((j*j)+(k*k))/4)-((j*k)/2)
            if temp > 0:
                z = math.sqrt(temp)-((j+k)/2)
                if z-int(z) == 0 and z > 0:
                    ans += 1
    print(ans)


Fixed submission:
import math

n = int(input())
ans_list = [0 for i in range(n+1)]

for i in range(1,101):
    for j in range(1, 101):
        for k in range(1, 101):
            temp = i*i + j*j + k*k + i*j + j*k + k*i
            if temp <= n:
                ans_list[temp] += 1

for i in range(1, n+1):
    print(ans_list[i])

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

n = int(input())

for i in range(1, n+1):
    ans = 0
    for j in range(1, int(math.sqrt(i))):
        for k in range(1, int(math.sqrt(i))):
            if i-(3*((j**2)+(k**2))/4)-((j*k)/2) > 0:
                z = math.sqrt(i-(3*((j**2)+(k**2))/4)-((j*k)/2))-((j+k)/2)
                if z-int(z) == 0 and z > 0:
                    ans += 1
    print(ans)


Fixed submission:
import math

n = int(input())
ans_list = [0 for i in range(n+1)]

for i in range(1,101):
    for j in range(1, 101):
        for k in range(1, 101):
            temp = i*i + j*j + k*k + i*j + j*k + k*i
            if temp <= n:
                ans_list[temp] += 1

for i in range(1, n+1):
    print(ans_list[i])
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_sum = 0
a_i = 0
flag = 0
for i in range(len(a)):
    if a_sum+a[i] <= k:
        a_sum += a[i]
    elif a_sum+a[i] > k:
        a_i = i-1
        break
if i == len(a)-1:
    a_i = len(a)-1

b_sum = 0
flag = 0
for i in range(len(b)):
    if b_sum+b[i] <= k:
        b_sum += b[i]
    elif b_sum+b[i] > k:
        b_i = i-1
        break
if i == len(b)-1:
    b_i = len(b)-1

ans = 0
temp = 0
a_temp = 0
b_temp = 0
if k < a[0] and k < b[0]:
    print(0)
else:
    while (k > a_sum or k > b_sum) and (a_sum > 0 or b_sum > 0):
        if (a_sum <= b_sum and a_sum > 0) or b_sum == 0:
            ans += 1
            k -= a[a_temp]
            a_sum -= a[a_temp]
            a_temp += 1
        elif b_sum > 0:
            ans += 1
            k -= b[b_temp]
            b_sum -= b[b_temp]
            b_temp += 1
        while a_sum > k and a_i != a_temp:
            a_sum -=a[a_i]
            if a_sum < 0:
                a_sum = 0
            a_i -= 1
        while b_sum > k and b_i != b_temp:
            b_sum -=b[b_i]
            if b_sum < 0:
                b_sum = 0
            b_i -= 1
    print(ans)


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

a_sum = [0]
for i in range(len(a)):
    a_sum.append(a_sum[len(a_sum)-1]+a[i])

b_sum = [0]
for i in range(len(b)):
    b_sum.append(b_sum[len(b_sum)-1]+b[i])

ans = 0
b_i = len(b_sum)-1

for i in range(len(a_sum)):
    if a_sum[i] > k:
        break
    else:
        if b_i > -1:
            while b_sum[b_i] + a_sum[i] > k and b_i > -1:
                b_i -= 1
            if b_i > -1 and ans < i+b_i:
                ans = i+b_i
        else:
            if a_i > ans:
                ans = a_i

print(ans)
Buggy python submission (verdict: Runtime Error):
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1

for i in range(0, 102):
    if i == 0:
        temp_abs = abs(x-i)
        if n_abs > temp_abs:
            n_abs = temp_abs
            ans = i
    else:
        temp_abs = abs(x-i)
        if n_abs > temp_abs and p_list[i-1] != 1:
            n_abs = temp_abs
            ans = i
        elif n_abs == temp_abs and i < ans and p_lsit[i-1] != 1:
            n_abs = temp_abs
            ans = i

print(ans)


Fixed submission:
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1

for i in range(0, 102):
    if i == 0 or i == 101:
        temp_abs = abs(x-i)
        if n_abs > temp_abs:
            n_abs = temp_abs
            ans = i
    else:
        temp_abs = abs(x-i)
        if n_abs > temp_abs and p_list[i-1] != 1:
            n_abs = temp_abs
            ans = i
        elif n_abs == temp_abs and i < ans and p_lsit[i-1] != 1:
            n_abs = temp_abs
            ans = i

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

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


temp = pow(10, 18)
ans = 1
flag = 0

for i in a:
    ans = ans * i

if ans <= temp:
    print(ans)
else:
    print(-1)


Fixed submission:
n = input()

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

temp = pow(10, 18)
ans = 1
flag = 0

if 0 in a:
    print(0)
    flag = 1
else:
    for i in a:
        ans = ans * i
        if ans > temp:
            print(-1)
            flag = 1
            break

if flag == 0:
    print(ans)