'use strict'
const main = input => {
  const n = parseInt(input[0], 0), p = input[1].split(' ').map(val => parseInt(val, 10));
  // console.log(n, p);
  let miss = 0;
  for(let i=0; i<n; i++) {
    if (p[i] != i+1) miss++ 
  }
  console.log(miss<=2?'YES':'NO');
  // console.log(miss);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));