#include <bits/stdc++.h>

using namespace std;

int p[300005];
bool vis[300005];

void check(int l,int r) {
  int max1=0,max2=0;
  for(int i=l;i<=r;i+=2)
    if (p[i]>i) {
    	if (p[i]<max1) {
    		puts("No");
    		exit(0);
		}
		max1=p[i];
	} 
	else {
		if (p[i]<max2) {
			puts("No");
			exit(0);
		}
		max2=p[i];
	}
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&p[i]);
  int l=1;
  while (l<=n) {
  	if (p[l]==l) l++;
	else {
		int r=l,s=1;
		vis[p[l]]=1;
		while (s) {
			if (r+2>n||p[r+1]!=r+1||p[r+2]==r+2) {
				puts("No");
				return 0;
			}
			r+=2;
			vis[p[r]]=1;
			if (p[r]>r) s++;
			if (vis[r]) s--;
		}
		check(l,r);
		l=r+1;
	}
  }
  puts("Yes");
  return 0;
}