#include<cstdio>
#include<iostream>
#include<cstring>
#define M 210
using namespace std;
int flag,a[M],n;
void tree(int x)
{
if(flag)return;
if(a[2*x])
{
if(a[2*x]<a[x])tree(2*x);
else
{
flag=1;
return;
}
}
else return;
if(a[2*x+1])
{
if(a[2*x+1]<a[x])tree(2*x+1);
else
{
flag=1;
return;
}
}
else return;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
tree(1);
if(flag)printf("No");
else printf("Yes");
return 0;
}