#include<algorithm>
#include<iostream>
#include<cstdio>

using namespace std;

int a[300005],n;

bool check(int o,int p)
{
	int mx=0,mm=n+1,s=0,ss=0;
	for(int i=o;i<=p;i++) mx=max(mx,a[i]),mm=min(mm,a[i]);
	if((mx!=p)||(mm!=o)) return false;
	for(int i=o;i<=p;i+=2)
	    if(a[i]>s) s=a[i];else if(a[i]>ss) ss=a[i];else return false;
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i) continue;
		int p;
		for(p=i;p<=n-2;p+=2)
		    if((a[p+1]!=(p+1))||(a[p+2]==(p+2))) break;
		if(!check(i,p)) {cout<<"No"<<endl;return 0;}
		i=p;
	}
	cout<<"Yes"<<endl;
	return 0;
}