模拟即可
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main()
{
    while(1){
        int N;
        cin>>N;
        if(N==0) break;  
        while(1){
            vector<int>a(N);
            stack<int>st;
            cin>>a[0];
            if(a[0]==0) break; 
            for(int i=1;i<N;i++){
                cin>>a[i];
            }
            int j=0,r=1;
            for(int i=1; i<=N; i++) {
                st.push(i);  
                while(!st.empty()&&st.top()==a[j]) {
                     st.pop();  
                     j++;      
                }
            }
            for(; j<N; j++){
                if(!st.empty() && a[j]==st.top()) st.pop();
                else {
                    cout<<"No"<<endl;
                    r=0;
                    break;
                }
            }
            if(r) cout<<"Yes"<<endl;
        }
        cout<<endl;
    }
    return 0;
}