while true
    n = gets.to_i
    break if n == 0
    arr = gets.chomp.split.map(&:to_i)
    start, prev, arr2 = arr[0], arr[0], []
    arr[1..-1].each{|x|
        if x != prev + 1
            arr2 << ((start == prev) ? start : "#{start}-#{prev}")
            start = x
        end
        prev = x
    }
    arr2 << ((start == prev) ? start : "#{start}-#{prev}")
    puts arr2.join(" ")
end
