class Solution:
    def longestConsecutive(self, nums):
        result = 0
        for x in nums:
            if x - 1 not in nums:
                y = x + 1
                while y in nums:
                    y += 1
                result = max(result, y - x)
        return result


print(Solution().longestConsecutive([100, 4, 200, 1, 3, 2]))