
class Notation
  def initialize(index, value)
    @index = index
    @value = value
  end

  def merge?(index, value)
    value == @value + (index - @index)
  end

  def merge(value)
    @last = value
  end

  def to_s
    @last ? "#{@value}-#{@last}" : @value.to_s
  end
end

while n = gets.chomp.to_i
  break if n == 0

  results = []

  list = gets.chomp.split(' ').map(&:to_i)

  now = Notation.new 0, list[0]
  results << now

  list.each_with_index do |value, index|
    next if index == 0
    now.merge value if now.merge? index, value

    if !now.merge?(index, value)
      now = Notation.new index, value
      results << now
    end
  end

  puts results.map(&:to_s).join(' ')

end