function main(input)
{
    const args = input.split('\n');
    const numbers = args[1].split(' ').map(x => parseInt(x, 10));
    // console.log(numbers);

    var answers = [];
    for (var i = 0; i < numbers.length; i++)
    {
    	answers.push(i + 1);
    }

    // console.log(answers);

    var count = 0;
    for (var i = 0; i < numbers.length; i++)
    {
    	count += (answers[i] === numbers[i]) ? 0 : 1
    }
    // console.log(count);

    const answer = (count === 2 || count === 0) ? 'YES' : 'NO';
    console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

// main(require("fs").readFileSync("/Users/hiroi_junki/IdeaProjects/atcoder/test_abc_135_b.txt", "utf8"));

