loop do
    n = gets.to_i
    break if n == 0
    a = []
    seq = []
    gets.split.map(&:to_i).sort.each do |i|
        if seq.empty?
            seq << i
        elsif seq[-1] + 1 == i
            seq << i
        else
            if seq.size == 1
                a << seq[0]
            else
                a << [seq[0], ?-, seq[-1]].join
            end
            seq = [i]
        end
    end
    if seq.size == 1
        a << seq[0]
    else
        a << [seq[0], ?-, seq[-1]].join
    end
    puts a * ' '
end

