import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] p = new int[n];
	foreach(i; 0..n) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	int[] a;
	bool prev = true;
	int s = 0;
	bool judge(int[] a) {
		//writeln(a);
		int n = a.length.to!int;
		if (n == 0) return true;
		if (n%2 == 0) {
			n--;
			a = a[0..n];
		}
		foreach (i; 0..n) {
			if (i%2 == 0) {
				if (a[i] < 0 || a[i] >= n) return false;
				if (a[i]%2 == 1) return false;
			} else {
				if (a[i] != i) return false;
			}
		}
		int l = -1, r = -1;
		foreach (i; 0..n) {
			if (i%2) continue;
			if (a[i] < i) {
				if (a[i] < l) return false;
				l = a[i];
			} else {
				if (a[i] < r) return false;
				r = a[i];
			}
		}
		return true;
	}
	foreach (i; 0..n) {
		if (p[i] == i) {
			if (prev) {
				if (!judge(a)) {
					writeln("No");
					return;
				}
				a = new int[0];
				s = i+1;
			} else {
				a ~= p[i]-s;
			}
			prev = true;
		} else {
			if (!prev) {
				if (!judge(a)) {
					writeln("No");
					return;
				}
				a = new int[0];
				s = i;
				a ~= p[i]-i;
			} else {
				a ~= p[i]-s;
			}
			prev = false;
		}
	}
	if (!judge(a)) {
		writeln("No");
	} else {
		writeln("Yes");
	}
}