const main = (lst,N) => {
    var count = 0
    for(var i = 0;i<lst.length;i++) {
        if(lst[i] != i+1) {
            count++
        }

    }
    if(count <= 2) {
        return "YES"
    }
    return "NO"
}

const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")
const N = Number(input[0])
const P = input[1].split(" ").map(x => Number(x))
console.log(main(P))