while n = gets.to_i
  break if n == 0
  l = gets.split.map(&:to_i)
  dif = l.zip(l[1..-1])[0...-1].map{ |v| v[1] - v[0] } << 2
  ret = []
  f = false
  n.times do |i|
    if dif[i] > 1
      if f
        ret[-1] = ret[-1] + "-" + l[i].to_s
        f = false
      else
        ret << l[i].to_s
      end
    else
      if !f
        ret << l[i].to_s
        f = true
      end
    end
  end
  puts ret.join(" ")
end