#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline int read(){
	int  ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int a[300005],n;
inline bool check(int l,int r)
{
	int mn=n+1,mx=0;
	for(int i=l;i<=r;i++) mn=min(mn,a[i]),mx=max(mx,a[i]);
	if(mn!=l||mx!=r) return 0;
	int x=0,y=0;
	for(int i=l;i<=r;i+=2)
	{
		if(x<a[i]&&y<a[i]) y=a[i];
		else if(x<a[i]) x=a[i];
		else return 0;
	}
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	for(int i=1;i<=n;i++)
	{
		if((a[i]&1)!=(i&1)){cout<<"No";return 0;}
	}	
	for(int i=1;i<=n-2;i++)
	{
		if(a[i]==i) continue;
		int k=i;
		while(k<=n-2)
		{
			if(a[k+1]!=k+1) break;
			if(a[k+2]==k+2) break;
			k+=2;
		}
		if(!check(i,k)){cout<<"No";return 0;}
		i=k;
	}
	cout<<"Yes";
	return 0;
}