---
# System prepended metadata

title: 1887. Reduction Operations to Make the Array Elements Equal
tags: [Leetcode, Sorting, Medium]

---

# 1887. Reduction Operations to Make the Array Elements Equal
###### tags: `Leetcode` `Medium` `Sorting`
Link: https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal/description/
## 思路
先排序
接下来遍历array 如果发现```nums[i-1]!=nums[i]``` 说明从i开始右边的所有数都要update一次
## Code
```python=
class Solution:
    def reductionOperations(self, nums: List[int]) -> int:
        nums.sort(reverse=True)
        ans = 0
        n = len(nums)
        for i in range(0, n-1):
            if nums[i]!=nums[i+1]:
                ans += i+1
        return ans
```