#C3654. Minimum Operations to Equalize a Sequence
Minimum Operations to Equalize a Sequence
Minimum Operations to Equalize a Sequence
You are given a sequence of n integers. In one operation, you can increase any element by 1. Your goal is to make all the elements in the sequence equal by using the minimum number of operations.
More formally, let \(a_1, a_2, \dots, a_n\) be the sequence and let \(m = \max\{a_1, a_2, \dots, a_n\}\). In one operation, you choose an index \(i\) and set \(a_i = a_i + 1\). The task is to compute the value:
\(\sum_{i=1}^{n}(m - a_i)\)
This value represents the minimum number of operations required to make the entire sequence equal.
inputFormat
The first line of input contains a single integer \(n\) representing the number of elements in the sequence.
The second line contains \(n\) space-separated integers which constitute the sequence.
outputFormat
Output a single integer, which is the minimum number of operations required to equalize the sequence.
## sample5
1 2 1 2 1
3
</p>