#include <bits/stdc++.h>

const int MAXN = 300010;
void bye() { std::cout << "No" << std::endl; exit(0); }
int A[MAXN], n;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i];
	auto typ = [] (int i) { return (A[i] == i) ^ (i & 1); };
	for (int l = 1, r; l <= n; l = r + 1) {
		if (A[l] == l) { r = l; continue; }
		for (r = l; r <= n; ++r)
			if (typ(l) != typ(r))
				break;
		--r;
		int inc = 0, dec = 0;
		for (int j = l; j <= r; j += 2) {
			if (A[j] > j) { if (A[j] < inc) bye(); inc = A[j]; }
			else { if (A[j] < dec) bye(); dec = A[j]; }
			if (dec != 0 && dec < l) bye();
			if (inc != 0 && inc > r) bye();
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}
