"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.split("\n");

const N   = Number(inputs[0]);
const arr = inputs[1].split(" ");

const main = (N, arr) => {
    let sorted = arr.concat().sort((a, b) => {return a - b});
    let cnt = 0;
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] != sorted[i]) {
            cnt++;
        }
    }

    if (cnt === 0 || cnt === 2) {
        return "YES";
    } else {
        return "NO";
    }
};
console.log(main(N, arr));