'use strict';(function(input){

  input=input.trim().split(/\s+/).map(x=>x-0);
  
  const N = input[0];
  var counter = 0;
  for(let i=1;i<=N;i++){
    if(i!==input[i]){
      counter++;
    }
  }
  if(counter<=2){
    console.log('YES');
  }else{
    console.log('NO');
  }
})(require('fs').readFileSync('/dev/stdin','utf8'));