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


for (var i = 0; i < count; ++i) {
	if (rawArray[i] !== (i + 1)) {
      ++counter;
      if (counter >= 2) {
        console.log('NO');
      	return;
      }
    }
}
console.log('YES');