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

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> p(n);
  for(Int i=0;i<n;i++) cin>>p[i],p[i]--;
  
  auto NO=[](){cout<<"No"<<endl;exit(0);};
  for(Int i=0;i<n;i++) if((i^p[i])&1) NO();

  vector<Int> s(n);
  for(Int i=0;i<n;i++) s[i]=p[i]==i;
  
  auto solve=
    [&](Int l,Int r){
      if(l==r){
	if(p[l]!=l) NO();
	return;
      }
      if(s[l]) l++;
      if(s[r]) r--;
      vector<Int> x,y,z;
      for(Int i=l;i<=r;i+=2)
	(i<p[i]?x:y).emplace_back(p[i]);
      if(!is_sorted(x.begin(),x.end())) NO();
      if(!is_sorted(y.begin(),y.end())) NO();
      merge(x.begin(),x.end(),y.begin(),y.end(),back_inserter(z));
      if(z.front()!=l) NO();
      if(z.back() !=r) NO();
    };
  
  for(Int i=0;i<n;i++){
    Int j=i;
    while(j+1<n&&s[j]!=s[j+1]) j++;
    solve(i,j);
    i=j;    
  }
  cout<<"Yes"<<endl;
  return 0;
}
