while n = gets.to_i
  break if n == 0
  s = gets.split
  i = 0
  while i < n
    s[i] = s[i].to_i
    i += 1
  end
  
  i = 1
  h = e = s[0]
  
  while i < n
    if e == s[i] - 1
      e = s[i]
    elsif h == e
      printf("%d ",h)
      h = e = s[i]
    else
      printf("%d-%d ",h,e)
      h = e = s[i]
    end
    i += 1
  end
  
  if h == e
    printf("%d\n",h)
  else
    printf("%d-%d\n",h,e)
  end
end