input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
p = lines.shift().split(' ')
a = 0
for (i=0; i<N; i++) {
    if (i+1 != p[i]) {
        a++
    }
    if (a > 2) {
        break;
    }
}
console.log(a == 0 || a == 2 ? 'YES' : 'NO')
