Python3 | Simple and easy | Explained
If list has only 1 element return 0 as no operation is performed\nIf list has more than one element then check for 1st and last element as 1st element will be 1
If list has only 1 element return 0 as no operation is performed\nIf list has more than one element then check for 1st and last element as 1st element will be 1 and last element will be 2*(n-1)+1(formula is given in question) 1st and last element will converge or become equal at their average value. So we have to make all elements\nof the array equal to that average value.\nWe will chose indexes as (1st and last element) then (2nd and 2nd last element) and so on...\nIn this approach we will increase the lower value(1st,2nd..) and decrease the higher value(last, 2nd last...) by 1\nwe see that operations are performed in a symmetric way. So we will just calculate the values for one half of\nthe array and add and store the results.\nHere I have done on the 2nd half you can do it for the first half if you like(from 0 to n//2)\n```\nclass Solution:\n    def minOperations(self, n: int) -> int:\n        # if there is only one element in list then its already equal so no need to perform any operation\n        if n==1:return 0\n        else:\n            a=1 # First value\n            b=2*(n-1)+1 # Last value\n            avg=(b+1)//2  # Taking average\n            res=0 # Counter for storing answer\n            for i in range(n//2,n): # Loop for 2nd half portion of the array\n                res+=abs((2*i+1)-avg)   # Taking the difference with average value and adding to the result\n            return res\n```\n**Please upvote if the solution helps.\nFeel free to ask any questions**
['Python']