'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const p = args[1].map(arg => parseInt(arg, 10))
	let flg = false

	let t2 = true
	for (let k = 0; k < n; k++) {
		if ((k + 1) !== p[k]) t2 = false
	}
	if (t2) flg = true
	
	for (let i = 0; i < n; i++) {
		for (let j = (i + 1); j < n; j++) {
			const t1 = p.slice()
			t1[i] = p[j]
			t1[j] = p[i]
			let t2 = true
			for (let k = 0; k < n; k++) {
				if ((k + 1) !== t1[k]) t2 = false
			}
			if (t2) flg = true
		}
	}

	if (flg) console.log('YES')
	else console.log('NO')
}

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