import java.util.*

fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val pages = readLine()!!.trim().split(' ').map(String::toInt)
        var i = 0
        val list = LinkedList<String>()
        while(i < n){
            val a = pages[i]
            var current = a
            while(i + 1 < n && pages[i + 1] == current + 1){
                current = pages[++i]
            }
            if (a != current){
                list.add("$a-$current")
            }else {
                list.add(a.toString())
            }
            ++i
        }
        println(list.joinToString(" "))
    }
}
