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();

  let count = 0;
  for(let i = 0; i < n; i++) {
    P[i] !== PSorted[i] && count++
    // console.log(P[i], PSorted[i])
    // console.log(count)
  }

  console.log(count > 3 ? 'NO' : 'YES')

}

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

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