#include <bits/stdc++.h>
using namespace std;

const int N = 300005;

int n, p[N];
int f[N][2];
vector <int> to_left, to_right;

bool increasing(vector <int> &a) {
	for (int i = 1; i < a.size(); ++i) {
		if (a[i] <= a[i - 1]) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}

	for (int i = 1; i <= n; ++i) {
		f[i][0] = f[i - 1][0];
		f[i][1] = f[i - 1][1];
		f[i][i % 2] += (p[i] == i);
	}

	for (int i = 1; i <= n; ++i) {
		int dif = i - p[i];
		if (dif % 2 != 0) {
			return cout << "No\n", 0;
		}
		if (dif == 0) continue;
		if (dif > 0) {
			if (f[i][1 - i % 2] - f[p[i]][1 - i % 2] != dif / 2 || f[i][i % 2] - f[p[i] - 1][i % 2] != 0) {
				return cout << "No\n", 0;
			}
			to_left.push_back(p[i]);
		}
		else { // dif < 0
			if (f[p[i]][1 - i % 2] - f[i][1 - i % 2] != -dif / 2 || f[p[i]][i % 2] - f[i - 1][i % 2] != 0) {
				return cout << "No\n", 0;
			}
			to_right.push_back(p[i]);
		}
	}

	if (increasing(to_left) && increasing(to_right)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}