const ascending_order_check = lst => {
    const result = lst.filter((n,index,self) => {return self[index+1] - n == 1 }).length
    return result
}
const main = (lst,N) => {
    if(ascending_order_check(lst) === N-1) {
        return "YES"
    }

    var tmplst = []
    for(var i = 0;i<lst.length;i++) {
        for(var j = (i+1);j<lst.length;j++) {
            tmplst = lst.slice(0,lst.length)
            const tmp = tmplst[i]
            tmplst[i] = tmplst[j]
            tmplst[j] = tmp
            if (ascending_order_check(tmplst) === (N-1)) {
                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,N))