
function Main(input) {
    var N = parseInt(input[0], 10);
    var P = input.slice(1).map(a => parseInt(a, 10));

    var no = 0;

    for (var i = 0; i < N; i++) {
        if (i + 1 !== P[i]) {
            no++;
        }
    }

    console.log(no <= 2 ? 'YES' :'NO');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));