Grouping Numbers from its sequence