#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=3e5+5;

int n,a[N];

bool check(int l,int r) {
	if (l==r) return a[l]==l;
	if (!((r-l+1)&1)) return 0;
	for(int i=l+1;i<=r-1;i+=2) if (a[i]!=i) return 0;
	for(int i=l;i<=r;i+=2) if (a[i]==i) return 0;
	int lst=0;
	for(int i=l;i<=r;i+=2)
		if (a[i]<i) {
			if (a[i]<lst) return 0;
			lst=a[i];
		}
	lst=0;
	for(int i=l;i<=r;i+=2)
		if (a[i]>i) {
			if (a[i]<lst) return 0;
			lst=a[i];
		}
	return 1;
}

int main() {
	n=read();
	fo(i,1,n) a[i]=read();
	int lst=0,mx=0;
	fo(i,1,n) {
		mx=max(mx,a[i]);
		if (mx==i) {
			if (!check(lst+1,i)) {puts("No");return 0;}
			lst=i;
		}
	}
	puts("Yes");
	return 0;
}