#include<vector>#include<map>#include<algorithm>#include<cmath>#include<set>#include<cstdio>#include<sstream>#include<string>#include<iostream>#include<iomanip>#include<stack>#include<utility>#include<unordered_map>#include<queue>#include<cstring>#include<deque>usingnamespace std;intmain(){constint MAXN =1000+10;int n, target[MAXN];while(scanf("%d",&n)==1&&n!=0){while(scanf("%d",&target[1])&& target[1]!=0){
stack<int>s;int A =1, B =1;for(int i =2; i <= n;++i){scanf("%d",&target[i]);}int ok =1;while(B <= n){if(A == target[B]){++A;++B;}elseif(!s.empty()&& s.top()== target[B]){ s.pop();++B;}elseif(A <= n){ s.push(A++);}else{
ok =0;break;}}printf("%s\n", ok ?"Yes":"No");}puts("");}}