var p=require("fs").readFileSync("/dev/stdin","utf8");
p = p.split("\n").map(a=>+a);
console.log(main());
function main(){
  var Y = "Yes", N = "No";
  var n = p[0];
  var a = Array(n+1).fill(0).map((x,y)=>y);
  for(var i = 1; i <= n; i++){
    var j = a[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;
      a[p[j]] = j; j -= 2;
    }
  }
  return Y;
}