"use strict";
function Main(input) {
  input = input.split("\n");
  let N = parseInt(input[0]);
  let P = input.slice(1).map(x => parseInt(x));
  for (let i = 0; i < N; i += 1) {
    if (P[i] === i + 1) continue;
    if (
      i + 2 < N &&
      P[i] > P[i + 1] &&
      P[i + 1] > P[i + 2] &&
      P[i + 2] === i + 1
    ) {
      let tmp = P[i + 2];
      P[i + 2] = P[i];
      P[i] = tmp;
      continue;
    }
    console.log("No");
    return;
  }
  console.log("Yes");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
