object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    var p = readLine().split(' ').map(_.toInt)
    var check = ""

    if(SortCheck(p)) check = "fin"
    if(check != "fin") {
      var f = -1
      var e = -1
      for(i <- 0 until p.size - 1) {
        if(p(i) > p(i + 1) && f == -1) f = i
      }
      for(i <- f until p.size - 1) {
        if(p(i) > p(i + 1)) e = i + 1
      }
      p = change(p,f,e)
    }
    if(SortCheck(p)) check = "fin"

    if(check == "fin") println("YES")
    else println("NO")
  }

  def SortCheck(p:Array[Int]) ={
    var flag = true
    for(i <- 0 until p.size - 1) {
      if(p(i) > p(i + 1)) flag = false
    }
    flag
  }

  def change(p:Array[Int],f:Int,e:Int) ={
    val temp = p(f)
    p(f) = p(e)
    p(e) = temp
    p
  }
}
