"use strict"
function main(arg) {
    var listSize = arg.trim().split("\n")[0];
    var listBase = arg.trim().split("\n")[1].split(" ");
    var list = [];
    var trueFlg = true;
    var count = 0;

    for(var i = 1; i <= listSize; i++){
        if(listBase[(i-1)] != i){
            trueFlg = false;
            count++;
        }
    }


    if(trueFlg == true || count == 2){
        console.log("YES");
    }else{
        console.log("NO");
    }


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