function main(input) {
    var n = input[0]-0;
    var str = input[1];
    var a = str.split(" ").map(v=>v-0);
    var b = str.split(" ").map(v=>v-0).sort((a,b)=>a-b);
    var ans = 0;
    for(var i=0;i<n;i++){
        if(a[i]!=b[i]) ans++;
    }
    console.log(ans<=2?"YES":"NO");
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
