#include<iostream>
#include<stack>
#include<queue>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
stack<int> station;
queue<int> b;
unsigned int N,f;
while(cin>>N){
if(N==0)
return 0;
while(true){
cin>>f;
if(f==0)
break;
b.push(f);
for(int i=1;i<N;++i){
cin>>f;
b.push(f);
}
for(int i=1;i<=N;++i){
while(!station.empty()&&b.front()==station.top()){
b.pop();
station.pop();
}
if(b.front()==i)
b.pop();
else
station.push(i);
}
while(!station.empty()&&b.front()==station.top()){
b.pop();
station.pop();
}
if(station.empty())
cout<< "Yes\n";
else
cout<< "No\n";
}
}
return 0;
}