#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 300005;

inline int read()
{
	int ret, f=1;
	char c;
	while((c=getchar())&&(c<'0'||c>'9'))if(c=='-')f=-1;
	ret=c-'0';
	while((c=getchar())&&(c>='0'&&c<='9'))ret=(ret<<3)+(ret<<1)+c-'0';
	return ret*f;
}

int n, a[maxn];

int s[maxn];

int lowbit(int x)
{
	return x & -x;
}

void modify(int x, int w)
{
	while(x <= n)
	{
		s[x] += w;
		x += lowbit(x);
	}
}

int query(int x)
{
	int ret = 0;
	while(x)
	{
		ret += s[x];
		x -= lowbit(x);
	}
	return ret;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; ++i)
		a[i] = read();
	int s1 = 0, s2 = 0, s3 = 0, res = 0;
	for(int i = 1; i <= n; i += 2)
	{
		s1 += res - query(a[i]);
		modify(a[i], 1);
		++ res;
	}
	for(int i = 1; i <= n; i += 2)
		modify(a[i], -1);
	res = 0;
	for(int i = 2; i <= n; i += 2)
	{
		s2 += res - query(a[i]);
		modify(a[i], 1);
		++ res;
	}
	for(int i = 2; i <= n; i += 2)
		modify(a[i], -1);
	for(int i = 1; i <= n; ++i)
	{
		s3 += i - 1 - query(a[i]);
		modify(a[i], 1);
	}
	printf("%s", (s1 + s2) * 3 == s3? "Yes": "No");
	return 0;
}