// Problem#: 1509
// Submission#: 1278196
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <stack>
#include <stdio.h>
using namespace std;
int main()
{
while (1)
{
int n,temp;
scanf ("%d",&n);
if (n == 0)
break;
while (scanf("%d",&temp) && temp != 0)
{
int k = 1;
stack<int> in;
for (int i = 0; i < n; i ++)
{
if (i != 0)
scanf ("%d",&temp);
if (in.empty())
in.push(k++);
while (temp != in.top() && temp > in.top())
in.push(k ++);
if (!in.empty())
in.pop();
}
if (in.empty())
printf ("Yes\n");
else
printf ("No\n");
}
printf ("\n");
}
return 0;
}