//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=310000;
	typedef long long ll;
	int mymin(int x,int y) {return x<y?x:y;}
	int myabs(int x) {return x>0?x:-x;}

	int a[MAX_N],b[MAX_N];
	bool check(int l,int r)
	{
		int left=0,right=0;
		for(int i=l;i<=r;i++)
		{
			if(a[i]<l or a[i]>r) return 0;
			if(a[i]<i)//left
			{
				if(left>a[i]) return 0;
				left=a[i];
			}
			else if(a[i]>i)
			{
				if(right>a[i]) return 0;
				right=a[i];
			}
		}
		return 1;
	}
	#define GG {puts("No");return;}
	void main()
	{
		int n;scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			if((a[i]-i)%2) GG//奇偶性
			b[i]=(a[i]==i);
			if(i>=3 and !b[i-2] and !b[i-1] and !b[i]) GG//连续三个动点
		}

		for(int l=1;l<=n;l++) if(b[l]==0)//动点
		{
			int now=1;//交替
			int r=l;while(r+1<=n and b[r+1]==now) now^=1,r++;
			if(!check(l,r)) GG
			l=r;
		}
		puts("Yes");
	}
};

int main()
{
	mine::main();
}
