'use strict';
 
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});
 
process.stdin.on('end', function() {
    inputString = inputString.split('\n');
    main();
});
 
function readline() {
    return inputString[currentLine++];
}
 
 
// main function .... code start ... ///
function main() {
 
//var input = readline()

var n = Number(readline());
var ar = readline().split(' ').map(x => parseInt(x));

var cnt = 0;
for(var i=0; i<n; i++) {
    if(ar[i] != (i+1)) cnt ++
}
console.log(cnt == 0 || cnt == 2 ? 'YES' : 'NO');

}

//