#C11555. Minimum Moves to Equal Array Elements
Minimum Moves to Equal Array Elements
Minimum Moves to Equal Array Elements
You are given an array of n integers. In one operation, you are allowed to increment n-1 elements by 1. The goal is to make all the elements equal in as few operations as possible.
It can be shown that the minimum number of operations required is given by the formula:
[ \text{operations} = \sum_{i=1}^{n} (a_i - \min(a)) ]
For example, if the array is [1, 2, 3], the answer is calculated as: (1-1) + (2-1) + (3-1) = 3.
Your task is to compute the minimum number of moves required to equalize the array elements.
inputFormat
The first line contains a single integer n (1 ≤ n ≤ 105), the number of elements in the array.
The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109), representing the array elements.
outputFormat
Output a single integer: the minimum number of operations required to make all the array elements equal.
## sample3
1 2 3
3
</p>