function Main(input) {
  input = input.split('\n')
  var N = parseInt(input[0])
  var p = input[1].split(' ').map(str => parseInt(str))
  var counter = 0

  for (var i = 0; i < N; i++) {
    if (p[i] !== i + 1) {
      counter++
    }
  }

  if (counter <= 2) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}

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

