### main

loop do
  n = gets.to_i
  break if n == 0

  pgs = gets.split.map(&:to_i)
  #p pgs

  ranges = []
  pr = nil

  for pg in pgs
    if pr.nil?
      pr = [pg, pg]
    elsif pr[1] + 1 == pg
      pr[1] = pg
    else
      ranges << pr
      pr = [pg, pg]
    end
  end
  ranges << pr if ! pr.nil?
  #p ranges

  puts ranges.map{|r| (r[0] == r[1]) ? r[0] : r.join('-')}.join(' ')
end