"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const P = arg[1].split(" ").map(n=>parseInt(n));
    
    let cnt = 0;
    
    for(let i=0; i<N-1; i++) {
        if(P[i] !== parseInt(i) + 1) {
            cnt++;
        }
    }

    console.log(cnt > 2 ? "NO" : "YES")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));