```
class Solution(object):
def longestConsecutive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
ss = []
for j in range(len(nums)):
if nums[j] not in ss:
ss.append(nums[j])
else:
continue
ss.sort()
l = len(ss)
c = 1
s = []
for i in range(l-1):
if ss[i+1]-ss[i]==1:
c += 1
s.append(c)
else:
s.append(c)
c = 1
if s:
length = max(s)
else:
length = 1
return length
```