#include <iostream>
#include <stack>
using namespace std;
int main()
{
int n;
while( cin >> n )
{
if( n == 0 ) break;
while( 1 )
{
int k[ n ] , p = 1 , i;
stack< int > s;
cin >> k[ 0 ];
if( k[ 0 ] == 0 ) break;
for( i = 1 ; i < n ; i++ ) cin >> k[ i ];
for( i = 0 ; i < n ; i++ )
{
if( ! s . empty() && s . top() == k[ i ] ) s . pop();
else if( k[ i ] >= p )
{
for( int l = p ; l < k[ i ] ; l++ ) s . push( l );
p = k[ i ] + 1;
}
else break;
}
if( i == n ) cout << "Yes" << endl;
else cout << "No" << endl;
}
cout << endl;
}
return 0;
}