Ruby Solution
\n# Code\n\n\ndef get_sum_absolute_differences(nums)\n  n = nums.count\n  left = 0\n  right = (1...n).map{|i| nums[i] - nums[0]}.sum\n  result = [right]\n  \n  
\n# Code\n```\n\ndef get_sum_absolute_differences(nums)\n  n = nums.count\n  left = 0\n  right = (1...n).map{|i| nums[i] - nums[0]}.sum\n  result = [right]\n  \n  (1...n).each do |i|\n    diff = nums[i] - nums[i-1]\n    right -= diff*(n - i)\n    left += diff*i\n    result << left + right\n  end\n  \n  result\nend\n```
['Ruby']