"use strict";
const main = arg => {
  let row1 = arg.split("\n")[1].split(" ").map(n => n*1);
  let sortrow = arg.split("\n")[1].split(" ").map(n => n*1).sort(
    (a, b)=>{return a - b})
  let count = 0;
  
  for(let i = 0; i < row1.length; i++){
  	if(sortrow[i] != row1[i]){
    	count++;
    }
  }
  let ans = (count == 2 || count == 0) ? "YES": "NO";
  console.log(ans);
}

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