#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
const int MaxN=300010;
int N,p[MaxN],q[MaxN];
bool vis[MaxN];
bool calc(){
	int cnt[2]={0},mx[2]={-1,-1},mn[2]={0,0};
	for(int i=0;i<N;i++){
		if(q[i]%2!=i%2)return 0;
		int j=q[i]/2;
		while(vis[mn[i&1]*2+i%2])mn[i&1]++;
		if(j!=mn[i&1]){
			if(mx[i+1&1]>=cnt[i+1&1])return 0;
			if(j<mx[i&1])return 0;
		}
		vis[j*2+i%2]=1;
		if(j>mx[i&1])mx[i&1]=j;
		cnt[i&1]++;
	}
	return 1;
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",p+i),q[--p[i]]=i;
	puts(calc()?"Yes":"No");
}