function Main(input) {
    input = input.split("\n");
    N = Number(input[0])
    tmp = input[1].split(" ");
    an = 0;
    for(i = 0; i < N; i++){
        tmp.push(Number(tmp[0]));
        tmp.shift();
    }
    for(j = 1; j <= N; j++){
        inj = tmp[j-1];
        if(inj == j) continue;
        tmp = swap(tmp,inj-1,j-1);
        an++;
    }
    console.log((an < 2) ? "YES" : "NO");
}
function swap(a,x,y){
    a[x]=[a[y],a[y]=a[x]][0];
    return a;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
