C++ math solution
Give a up if u like it\n\n###### For the first element you have to subtract all the extra valus from the total sum. For any other element u have to subtract the
# `Give a up if u like it`\n\n###### For the first element you have to subtract all the extra valus from the total sum. For any other element u have to subtract the excess from the right side and add the remaining from the left side.\n\n\n---\n`Explaination`\n\n    ex :   \n    nums = [1,4,6,8,10]\n    Output: [24,15,13,15,21]\n    sub-array sum = [1,5,11,19,29]\n    For the element 6   \n\n>     right side ans including itself \n\n    = 29 - (6  * no. of elements right side of 6 including it)\n     - sub array sum before 6 \n     \n    = 29 - 6*3 -5 = 6\n\t\n>     left side ans  excluding itself\n\n    = (6  * no. of elements left side of 6 excluding it) \n        - sub array sum before 6\n\n     = 6*2 - 5 = 7\n\n>      ans =  right side ans  + left side ans = 6+7 = 13\n\n\n---\n\n\n``code``\n   ```\n vector<int> getSumAbsoluteDifferences(vector<int>& nums) {\n        vector<int> subm;\n        vector<int> ans;\n       int n =nums.size();\n        int sum = 0;\n        for(int i= 0;i<n;i++){\n            sum +=nums[i];\n            subm.push_back(sum);\n        }\n      \n            \n        int total = subm[n-1];\n        //cout<<total;\n         for(int i= 0;i<n;i++){\n            \n                if(i==0) {\n                    int temp = total - (n)*nums[i];\n                    ans.push_back(temp);\n                }\n             else {\n                int tem = total - ((n-i) * nums[i]) + (i * nums[i]) - 2*subm[i-1];\n                ans.push_back(tem);\n             }\n               \n        }\n        return ans;\n    }\n\n```
['Math', 'C++']