#include <bits/stdc++.h>

const int N = 300054;

int n, a[N];
bool diff[N];

int main() {
	int i, j, lower, upper;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", a + i), diff[i] = a[i] != i;
	for (i = 2; i < n && !(diff[i - 1] && diff[i] && diff[i + 1]); ++i);
	if (i < n) return puts("No"), 0;
	for (j = i = 1; i <= n; i = j) {
		for (; j <= n && (diff[i] ^ diff[j] ^ i ^ j ^ 1) & 1; ++j);
		if ((i += !diff[i]) == j) continue;
		for (lower = upper = i; i < j; i += 2)
			if (a[i] < i) lower = (a[i] >= lower ? a[i] : INT_MAX);
			else upper = (a[i] >= upper ? a[i] : INT_MAX);
		if (lower >= j || upper >= j) return puts("No"), 0;
	}
	return puts("Yes"), 0;
}