Converts sequential numbers to ranges