#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 3e5+5; int n,p[N],stk[N],top;
	il bool solve(int l,int r) {
		int mx = 0,x = top = 0; rep(i,l,r) if ((i-l)&1) {if (p[i] < x) return 1; x = p[i];}
			else {if (p[i] < mx) {while(top && stk[top] < p[i]) --top; stk[++top] = p[i];} else mx = p[i]; if (top > 1) return 1;} return 0;
	}
	void main() {
		int l = 1,r = 0; n = read(); rep(i,1,n) if (((p[i] = read())-i)&1) {puts("No"); return;}
		rep(i,1,n) if ((r = max(r,p[i])) == i) {if (solve(l,r)) {puts("No"); return;} l = i+1;} puts("Yes");
	}
}
int main() {
	qiqi::main(); return 0;
}