```
def isPossible(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
d={}
for v in nums:d[v]=d.get(v,0)+1
l,h=nums[0],nums[-1]
c=d[l]
stack=[l]*c
for k in range(l+1,h+1):
if k not in nums:
return k-stack[-1]>=3
if d[k]>c:
stack+=[k]*(d[k]-c)
elif d[k]<c:
t2=c-d[k]
if t2>len(stack) or k-stack[t2-1]<3:return False
stack=stack[t2:]
c=d[k]
return not stack or h-stack[-1]>=2
```