function main(arg) {
    var N = parseInt( arg.split(/\n/)[0] );
    var p = arg.split(/\n/)[1].split(/\s/);
    var jk = [];
    //雛形の用意
    var ideal = p.slice();
    ideal.sort(sortfunc);
    //比較
    for(i=0;i<N;i++){
        if(p[i]!==ideal[i]){
            jk.push(i);
        }
    }
    if(jk.length = 2 && p[jk[0]]==ideal[jk[1]] && p[jk[1]]==ideal[jk[0]]){
        console.log("YES");
    }else{
        console.log("NO");
    }
}

function sortfunc(a,b){
    return parseInt(a)-parseInt(b);
}

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