function Main(input) {
  input = input.split("\n");
  const n = parseInt(input[0].split(" ")[0], 10);
  const P = input[1].split(" ");

  const PSorted = P.concat().sort();

  var count = 0;

  for (var i = 0; i < n; i++) {
    P[i] !== PSorted[i] ? count++ : null;
  }

  console.log(count === 2 || count === 0 ? 'YES' : 'NO');
}

// *出力
// number
// console.log('%d', );
// string
// console.log('%s', );

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
