#include <iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#define LL long long
const int MAXN = 1000+10;
int n,target[MAXN];
int main()
{
while(~scanf("%d",&n))
{
stack<int> s;
int A=1,B=1,i;
for(i =1 ;i<=n;i++)
scanf("%d",&target[i]);
int ok=1;
while(B<=n)
{
if(A==target[B])
{
A++;
B++;
}
else if(!s.empty()&&s.top()==target[B])
{
s.pop();
B++;
}
else if(A<=n)
s.push(A++);
else
{
ok=0;
break;
}
}
printf("%s\n",ok ? "Yes" : "No");
}
return 0;
}