#include <iostream>
#include <cstdio>
using namespace std;
int a[1000006];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++ i)
		if (a[i] != i){
			int j = i;
			bool tmp = false;
			while (((a[j] != j) ^ tmp) && j <= n){
				++ j;
				tmp = ! tmp;
			}
			bool flag = false;
			int lastl = 0, lastr = 0;
			for (int k = i; k < j; ++ k){
				if (a[k] < i || j <= a[k]){
			//		cout << a[k] << " " << i << " " << j << endl;
					flag = true;
				}
				if (a[k] < k){
					if (lastl < a[k])
						lastl = a[k];
					else
						flag = true;
				}
				if (a[k] > k){
					if (lastr < a[k])
						lastr = a[k];
					else
						flag = true;
				}
			}
			if (flag){
				cout << "No" << endl;
				return 0;
			}
			i = j - 1;
		}
	cout << "Yes" << endl;
	return 0;
}
