#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
int n,pre[MAXN],nxt[MAXN],a[MAXN],flag;
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2!=i%2) flag=1;
	}
	
	for(re int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
	memset(nxt,100,sizeof(nxt));
	for(re int i=n;i>=1;i--) nxt[i]=min(nxt[i+1],a[i]);
	for(re int i=2;i<=n-1;i++)
		if(a[i]!=i&&nxt[i+1]<a[i]&&pre[i-1]>a[i])
			flag=1;
	for(re int i=1;i<=n-1;i++)
		if(((a[i]==i)==(a[i+1]==i+1))&&pre[i]!=i)
			flag=1;
	if(flag) cout<<"No";
	else cout<<"Yes";
}