Raise Everyone Up
One move adds 1 to any single element. Print the minimum moves so all elements equal the (final) maximum — i.e. raise everything to the current maximum.
Input: the first line has N; the second line has N integers.
Output: ∑ (max − ai).
Constraints:
- 1 ≤ N ≤ 105
- |ai| ≤ 109
Sample Tests
Input 1
3 1 2 3
Output 1
3
Input 2
2 7 7
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.