function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var Y = "Yes", N = "No";
  var n = o.a();
  var p = [];
  for(var i = 0; i < n; i++){
    p[i] = o.a() - 1;
    if((i & 1) !== (p[i] & 1)) return N;
  }
  for(i = 0; i < n; i++){
    var j = i;
    while(p[j] > i){
      j++;
      if(p[j] !== j)return N;
      j++;
    }
    while(j > i){
      if(p[j-2] < p[j-1] || p[j-1] < p[j])return N;
      var t = p[j-2]; p[j-2] = p[j]; p[j] = t; j -= 2;
    }
  }
  return Y;
}