Python3 | Brute Force
Following the problem statement as it is, the following code is designed. \n\n1. Generate the array of numbers following the rule: arr[i] = (2 * i) + 1\n2. Calc
Following the problem statement as it is, the following code is designed. \n\n1. Generate the array of numbers following the rule: arr[i] = (2 * i) + 1\n2. Calculate the middle/converging (mid) value for the array:\n\t* \tIf the number **n** is even, the converging value for the array is **sum(middle two elements of the array) / 2** which is equal to **n**.\n\t* \tIf the number **n** is odd, the converging value for the array is the **middle element of the array**.\n3. Traverse through the array and sum up the difference of the element in the array with the converging value. *abs(num - mid)*\n4. Since at a time 2 operations can be done *(In one operation, you can select two indices x and y)*, divide the final result by 2.\n\n```\n\t\tnums = []        \n        for i in range(n):\n            nums.append((2 * i) + 1)\n        \n        res, mid = 0, 0\n        if n % 2 == 0:\n            mid = n\n        else:\n            mid = nums[len(nums) // 2]\n        for num in nums:\n            res += abs(num - mid)\n        return res // 2\n```
['Python', 'Python3']