#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

void ok(){
	cout << "Yes" << endl;
	exit(0);
}

void ng(){
	cout <<  "No" << endl;
	exit(0);
}

int p[324000], n;

bool mysort(int l, int r){
	vector<int> hoge;
	bool res = false;
	int k = 0;
	
	for(int i = l;i < r;i+=2){
		if(!hoge.empty() && hoge.back() > p[i])res = true; 
		hoge.push_back(p[i]);
	}
	sort(hoge.begin(), hoge.end());
	k = 0;
	for(int i = l;i < r;i+=2){
		p[i] = hoge[k++];
	}
	hoge.clear();

	for(int i = l+1;i < r;i+=2){
		if(!hoge.empty() && hoge.back() > p[i])res = true; 
		hoge.push_back(p[i]);
	}
	sort(hoge.begin(), hoge.end());
	k = 0;
	for(int i = l+1;i < r;i+=2){
		p[i] = hoge[k++];
	}
	return res;
}

int main(){
	cin >> n;
	for(int i  = 0;i < n;i++){
		cin >> p[i];
		if(i % 2 == p[i] % 2)ng();
	}

	for(int k = 0;k < 1000;k++){
		for(int i = n-3;i >= 0;i--){
			int a = p[i], b = p[i+1], c = p[i+2];
			if(a > b && b > c){
				swap(p[i], p[i+2]);
			}
		}
	}
		for(int i = 1;i < n-1;i++){
		int a = p[i-1], b = p[i], c = p[i+1];
		if((a > c) && (a < b || b < c))ng();
	}

	for(int i = 0;i+3 < n;i++){
		int a = p[i], b = p[i+1], c = p[i+2], d = p[i+3];
		if(a > b && b > c && c > d)ng();
	}
	ok();
}