var lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'),
    count = parseInt(lines[0]),
    nums = lines[1].split(/\s+/).map(function (n) { return parseInt(n, 10); }),
    counter = 0;
 
 
for (var i = 0; i < count; ++i) {
	if (nums[i] !== (i + 1))
      ++counter;
}
console.log(counter === 0 || counter === 2 ? 'YES' : 'NO');
