var lines = require('fs').readFileSync('/dev/stdin', 'utf8'),
    count = parseInt(lines[0]),
    rawArray = lines[1].split(' ').map(parseInt),
    counter = 0;


rawArray.forEach(function (v, i) {
	if (v !== (i + 1)) {
    	++counter;
      	if (counter > 1) {
          console.log('NO');
          return;
        }
    }
});
console.log('YES');