var p=require("fs").readFileSync("/dev/stdin","utf8");
p = p.split("\n").map(a=>+a);
console.log(main());
function main(){
  var N = "No";
  var n = p[0];
  for(i = 1; i <= n; i++){
    if(p[i] === i)continue;
    var u = p[i], v = i;
    while(i < u){
      i++;
      if(p[i] !== i)return N;
      i++;
      if(u + 2 === p[i])u = p[i];
      else if(v === p[i])v += 2;
      else return N;
    }
  }
  return "Yes";
}