#include <bits/stdc++.h>

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 4e5 + 10;
int tr[N], a[N], n;
LL a1, a2, a3;

void Modify(int x, int y) {
	for (; x <= n; x += x & -x) tr[x] += y;
}

int ask(int x) {
	int res = 0;
	for (; x; x -= x & -x) res += tr[x];
	return res;
}

int main() {
	n = read();
	for (int i = 1; i <= n; ++ i) {
		a[i] = read();
		if ((a[i] & 1) != (i & 1)) return puts("No"), 0;
		a1 += ask(n) - ask(a[i]);
		Modify(a[i], 1);
	}
	if (a1 % 3) return puts("No"), 0;
	memset(tr, 0, sizeof(tr));
	for (int i = 1; i <= n; i += 2) {
		a2 += ask(n) - ask(a[i]);
		Modify(a[i], 1);
	}
	memset(tr, 0, sizeof(tr));
	for (int i = 2; i <= n; i += 2) {
		a3 += ask(n) - ask(a[i]);
		Modify(a[i], 1);
	}
	if ((a2 + a3) * 3 != a1) return puts("No"), 0;
	puts("Yes");
	return 0;
}