Python3: 84 ms
\nclass Solution:\n    def numMovesStonesII(self, stones: List[int]) -> List[int]:\n        stones.sort()\n        ma=max(stones[-1]-stones[1]-len(stones)+2,sto
```\nclass Solution:\n    def numMovesStonesII(self, stones: List[int]) -> List[int]:\n        stones.sort()\n        ma=max(stones[-1]-stones[1]-len(stones)+2,stones[-2]-stones[0]-len(stones)+2)\n        mi=0\n        l=len(stones)\n        for i in range(l-1):\n            if stones[i]<=stones[-1]-l+1:\n                k=bisect.bisect(stones,stones[i]+l-1)\n                if i==0:\n                    if stones[0]+l-1 in stones:\n                        mi=max(mi,k)\n                    else:\n                        mi=max(mi,min(l-2,k))\n                else:\n                    mi=max(mi,k-i)\n        return [l-mi,ma]\n```
[]