values of length n. In one move you pick any n - 1 elements and add 1 to each of them.
Return the minimum number of moves after which all elements are equal.values=[2, 5, 3] → 4
A move only changes the gap between the skipped number and the rest, so always skip a maximum: [2,5,3] → [3,5,4] → [4,5,5] → [5,6,5] → [6,6,6]. That is 4 moves = (2 + 5 + 3) - 3 · 2.
values=[7, 7] → 0
The numbers are already equal.
values=[-4] → 0
values=[2, 5, 3]
4
Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.