Java 🔥 Solution ✅
Code\n\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n        int  ans = -1;\n        int minDiff = Int
# Code\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n        int  ans = -1;\n        int minDiff = Integer.MAX_VALUE;\n\n        long preSum = 0, totalSum = 0;\n        for(int num: nums){\n            totalSum += num;\n        }\n\n        for(int i = 0; i < n; i++){\n            preSum += nums[i];\n            long leftAvg = preSum / (i + 1);\n            long rightAvg = (totalSum - preSum);\n            if(i != n - 1){\n                rightAvg /= (n - i - 1);\n            }\n\n            int currDiff = (int) Math.abs(leftAvg - rightAvg);\n            if(currDiff < minDiff){\n                ans = i;\n                minDiff = currDiff;\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Array', 'Prefix Sum', 'Java']