#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[301000], BIT[301000][2];
void Add(int a) {
	int ck = a % 2;
	while (a <= n) {
		BIT[a][ck]++;
		a += (a&-a);
	}
}
int Sum(int a, int ck) {
	int r = 0;
	while (a) {
		r += BIT[a][ck];
		a -= (a&-a);
	}
	return r;
}
int main() {
	int i;
	scanf("%d", &n);
	long long s = 0, s2 = 0;
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		Add(w[i]);
		int c1 = Sum(n, 0) - Sum(w[i], 0);
		int c2 = Sum(n, 1) - Sum(w[i], 1);
		s += c1 + c2;
		if (w[i] % 2 != i % 2) {
			puts("No");
			return 0;
		}
		if (i % 2)s2 += c2;
		else s2 += c1;
	}
	if (s % 3 || s/3 < s2) {
		puts("No");
		return 0;
	}
	puts("Yes");
}