#C1116. Minimum Operations to Equalize Array Elements
Minimum Operations to Equalize Array Elements
Minimum Operations to Equalize Array Elements
Given an array of n integers, determine the minimum number of operations required to make all elements equal. In one operation, you can increment all elements except one by 1.
Mathematically, let \(a_1, a_2, \dots, a_n\) be the array elements and \(m = \min_{1 \leq i \leq n} a_i\). The minimum number of operations needed is:
\(\displaystyle \sum_{i=1}^{n} (a_i - m)\)
inputFormat
The first line contains a single integer n denoting the number of elements in the array. The second line contains n space-separated integers representing the array elements.
outputFormat
Output a single integer, which is the minimum number of operations required to equalize all the array elements.
## sample5
1 2 3 4 5
10
</p>