JAVA - EASY
\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        long totalSum = 0;\n        for(int num: nums) {\n            totalSum += num
```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        long totalSum = 0;\n        for(int num: nums) {\n            totalSum += num;\n        }\n\n        long currSum = 0, minAvgDiff = Integer.MAX_VALUE;\n        int minAvgIdx = 0;\n        for(int idx = 0; idx<nums.length; idx++) {\n            currSum += nums[idx];\n            long leftAvg = currSum/(idx+1);\n            long rightSum = totalSum - currSum;\n            boolean isLastElement = idx == nums.length-1;\n            long rightAvg = isLastElement ? 0 : rightSum/(nums.length-idx-1);    \n            long diffAvg = Math.abs(leftAvg-rightAvg);\n            \n            if(diffAvg<minAvgDiff) {\n                minAvgDiff = diffAvg;\n                minAvgIdx = idx;\n            }\n        }\n        \n        return minAvgIdx;\n    }\n}\n```
['Java']