prefix sum method
\nclass Solution:\n    def getDiff(self, prefix, i, n):\n        l = (prefix[i + 1] - prefix[0])\n        r = prefix[-1] - l\n        l = l // (i + 1)\n        
```\nclass Solution:\n    def getDiff(self, prefix, i, n):\n        l = (prefix[i + 1] - prefix[0])\n        r = prefix[-1] - l\n        l = l // (i + 1)\n        r = r // (n - i - 1) if i < n - 1 else 0\n        return abs(l - r)\n    \n    def minimumAverageDifference(self, nums: List[int]) -> int:\n        n = len(nums)\n        prefix = [0]\n        for i in range(n):\n            prefix.append(prefix[-1] + nums[i])\n        return min(range(n), key = lambda i: self.getDiff(prefix, i, n))\n```
['Python']