#38470: python


qazwsx960527@gmail.com (陳康曄)

學校 : 不指定學校
編號 : 242723
來源 : [36.230.145.147]
最後登入時間 :
2023-10-01 16:52:02

while True:
    n=int(input())
    if n==0:
        break
    while True:
        num=list(map(int,input().split()))
        if num==[0]:
            break
        stack=[0]
        y=[i for i in range(1,n+1)]
        f=True
        for i in num:
            while True:
                if i==stack[-1]:
                    stack.pop()
                    break
                elif i>stack[-1]:
                    stack.append(y.pop(0))
                elif i<stack[-1]:
                    f=False
                    break
            if f==False:
                print("No")
                break
        else:
            print("Yes")