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

int n,a[300010],t[300010];
long long s1,s2;

void add(int x) {for (; x; x-=(x&-x)) t[x]++;}
int query(int x) {int ans=0; for (; x<=n; x+=(x&-x)) ans+=t[x]; return ans;}

int main()
{
	scanf("%d",&n),s1=s2=0;
	for (int i=1; i<=n; i++) 
	{
		scanf("%d",&a[i]);
		if ((a[i]&1)!=(i&1)) return puts("No"),0;
	}
	memset(t,0,sizeof(t));
	for (int i=1; i<=n; i++) s1+=query(a[i]),add(a[i]);
	if (s1%3!=0) return puts("No"),0;
	memset(t,0,sizeof(t));
	for (int i=1; i<=n; i+=2) s2+=query(a[i]),add(a[i]);
	memset(t,0,sizeof(t));
	for (int i=2; i<=n; i+=2) s2+=query(a[i]),add(a[i]);
	if (s2!=s1/3) return puts("No"),0;
	return puts("Yes"),0;
}