[C++] EASY TO UNDERSTAND
In sorted array, an element will greater than every element on its left and smaller than every element on its right. So the difference of this element is this e
In sorted array, an element will greater than every element on its left and smaller than every element on its right. So the difference of this element is this element * appropriate_amount - sum of every smaller elements + sum of every greater elements -  this element * appropriate_amount. If my solution is helpful, give me an upvote. Thank you for reading.\n```\nclass Solution {\npublic:\n    vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        int sum=0;\n        for(int i=0; i<nums.size(); i++){\n            sum+=nums[i];\n        }\n        vector<int> result;\n        int leftsum=0;\n        int rightsum=0;\n        for(int i=0; i<nums.size(); i++){\n            leftsum+=nums[i];\n            rightsum=sum-leftsum;\n            result.push_back(nums[i]*(i+1)-leftsum+rightsum-nums[i]*(nums.size()-1-i));\n        }\n        return result;\n    }\n};
['C']