A consecutive sequence has a starting number. For , the start is . You know is a start if does not exist in the array.
For each potential start, count how many consecutive numbers follow it. Use a set for membership checks.
This avoids counting the same sequence multiple times. You only start counting from the beginning of each sequence.