C++ Simple Solution using sorting
Complexity\n- Time complexity:\nO(n log n)\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& nums) {\n        
# Complexity\n- Time complexity:\nO(n log n)\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimizeSum(vector<int>& nums) {\n        int n = nums.size();\n        sort(nums.begin(), nums.end());\n       \n        // nums[0] = nums[n-1], nums[1]=a[n-1]  for mx1\n        int mx1 = abs(nums[n-1]-nums[2]);\n\n        // nums[n-2] = nums[0], nums[n-1]=nums[0]  for mx2\n        int mx2 = abs(nums[n-3]-nums[0]);\n        \n        // nums[n-1] = nums[n-2], nums[0]=nums[1]  for mx3\n        int mx3 = nums[n-2]-nums[1];\n       \n       // min is always 0.\n\n        return min(mx1, min(mx2, mx3));\n    }\n};\n```
['Sorting', 'C++']