#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int a[300010];
bool check(int l,int r){
	int maxx=0,minn=0x7fffffff,i,j;
	for(i=l;i<=r;++i){maxx=max(a[i],maxx);minn=min(a[i],minn);}
	if(maxx!=r || minn!=l)  return false;
	int x=0,y=0;
	for(i=l;i<=r;i=i+2){
		if(x<a[i] && y<a[i])  y=a[i];
		else{
			if(x<a[i])  x=a[i];
			else  return false;
		}
	}
	return true;
}
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i)  scanf("%d",&a[i]);
	for(i=1;i<=n;++i){
		if((i&1)^(a[i]&1)){printf("No\n");return 0;}
	}
	for(i=1;i<=n-2;++i){
		if(a[i]==i)  continue ;
		j=i;
		while(j<=n-2){
			if(a[j+1]!=j+1)  break ;
			if(a[j+2]==j+2)  break ;
			j+=2;
		}
		if(!check(i,j)){printf("No\n");return 0;}
		i=j;
	}
	printf("Yes\n");
	return 0;
}