import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main {
  def main(args: Array[String]): Unit = {
    loop()

    def loop(): Unit = {
      val n = readInt()
      if (n != 0) {
        var t = readLine().split(' ').map(s => s.toInt)
        t = t :+ Int.MaxValue
        var ans: Seq[String] = Seq[String]()
        var preIdx = 0

        for (i <- 1 to n) {
          if (t(i - 1) + 1 != t(i)) {
            if (i - preIdx == 1) {
              ans = ans :+ t(i - 1).toString
            } else {
              ans = ans :+ s"${t(preIdx)}-${t(i - 1)}"
            }
            preIdx = i
          }
        }
        println(ans.mkString(" "))
        loop()
      }
    }
  }
}