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)) {
      console.log(nums[i], i+1);
      if (counter >= 2) {
        console.log('NO');
      	return;
      }
    }
}
console.log('YES');