object Main extends App {
  var a = readInt
  var b = readLine.split(" ").map(_.toInt)
  var c = b.sorted
  var sum = 0
  for(i <- 0 until a) {
    if(b(i)!=c(i)) {
      sum = sum + 1
    }
  }
  print(if(sum > 2){"NO"} else {"YES"})
}