I have no idea how I solved this
Code\npython3 []\nclass Solution:\n    def numMovesStonesII(self, a: List[int]) -> List[int]:\n        n = len(a)\n        a.sort()\n        \n        maxi = 1 
# Code\n```python3 []\nclass Solution:\n    def numMovesStonesII(self, a: List[int]) -> List[int]:\n        n = len(a)\n        a.sort()\n        \n        maxi = 1 - min(a[1] - a[0], a[-1] - a[-2])\n        for i in range(1, n):\n            maxi += a[i] - a[i-1] - 1\n        \n        mini = sys.maxsize\n        j = 0\n        for i in range(n):\n            while j < n and a[j] - a[i] <= n - 1:\n                j += 1\n            x = n - j + i\n            if x == 1 and a[j-1] - a[i] == j - i - 1:\n                x += 1\n            mini = min(mini, x)\n\n        return [mini, maxi]\n```
['Python3']