#include<cstdio>
#include<iostream>
#include<stack>
using namespace std;
int main()
{
int n,i,k;
int a[1010];
stack<int> s;
while(scanf("%d",&n),n)
{
while(scanf("%d",&a[1]))
{
if(a[1]==0)
{
printf("\n");
break;
}
while(!s.empty()) //初始化清空栈
s.pop();
k=1;
for(i=2;i<=n;++i)
scanf("%d",&a[i]);
for(i=1;i<=n;++i)
{
s.push(i);
if(i==a[k])
{
while(!s.empty()&&s.top()==a[k])
{
s.pop();
++k;
}
}
}
if(s.empty())
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}