class Q1051
  def citation n,ary
    p = ary[0]
    start = ary[0]
    for i in 1..n-1
      if ary[i] == p+1 
        p += 1
      else 
        if start == p
          print(p.to_s + " ")
        else
          print(start.to_s + "-" + p.to_s + " ")
        end
        p = ary[i]
        start = ary[i]
      end
    end
    if start == p
       puts p
    else
       puts(start.to_s + "-" + p.to_s)
    end
  end
  def doIt
    n = gets.to_i
    while n > 0
      ary = gets.split(" ").map {|x| x.to_i}
      citation n,ary
      n = gets.to_i
    end
  end
end

Q1051.new.doIt