Greedy Solution
\n\n# Approach\nhum greedy approach laga raha hai jaha pe  3 conditions possible hai .\n1. Starting ke 2 elements equal kar do \n2. Last ke 2 elements  equal ka
\n\n# Approach\nhum greedy approach laga raha hai jaha pe  3 conditions possible hai .\n1. Starting ke 2 elements equal kar do \n2. Last ke 2 elements  equal kar do \n3. First aur last ke 2 elements equal kar do\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int minimizeSum(int[] nums) {\n\n        int n = nums.length ;\n        if(n <= 3){\n            return 0;\n        }\n        Arrays.sort(nums);\n        int op1 = nums[n-1] - nums[2];\n        int op2 = nums[n-3] - nums[0];\n        int op3 = nums[n-2] - nums[1];\n        return Math.min(op1 , Math.min(op2, op3));\n    }\n}\n```
['Java']