'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a1 = arr[1].split(' ').map(x => Number(x));
  const a2 = a1;
  const b = a2.sort(compare);
  let count = 0;

  function compare(a, b) {
    return a - b;
  }

  for (let i = 0; i < a1.length; i ++) {
    if (a1[i] !== b[i]) {
      count ++;
    }
  }
  
  console.log(count === 2 ? 'YES' : 'NO');
}

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