/*铁轨*/
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string>
using namespace std;
const int max = 1000;
int a[max];
int b[max];
int main()
{
int n;
while (scanf("%d",&n))
{
memset(a, 0, sizeof(a));
for (int i = 1; i <= n; i++)
{
cin >> b[i];
}//要求的顺序
int j = 1;
int ok = 1;
int B = 1;
int count = 0;
while (ok!=0)
{
if (j == b[B])
{
j++;
B++;
}//找到已经进入C站的可以对应的第一个值
else if (count&&a[count] == b[B])
{
count--;
B++;
}//找到可以对应的第一个值之后,释放储存的值
else if (j <= n)
{
count++;
a[count] = j;
j++;
}//在未找到最大值之前,先把数字储存起来
else
{
ok = 0;
}
}
printf("%s\n", ok == 0 ? "no" : "yes");
}
system("pause");
return 0;
}