I ran into a programming problem that goes something like this:
Given a non-empty integer array of size n, find the minimum number of moves it takes to make all the integers equal, where a move means incrementing n-1 integers by 1.
It turns out that incrementing n-1 numbers has the "same effect" as decrementing a single number. By "same effect", I mean it takes the same number of steps to make all the integers equal. Basically, I find the minimum element and return the sum of differences for all the integers in the array.
However, I could not prove that this was the case. I got the correct answer but it was more of a guess. How can a proof be constructed to show that the two strategies would take the same number of steps?
Just pay attention what matters is the relative differences between elements of an array. If $A$ is an array, and $I$ is the array of all ones, then from this problem's point of view
$A= A+nI$
where $n$ is an integer. It means $A$ and $A+nI$ are equivalent.
If you look at the first operation in another way, you might see both algorithms are equivalent. Instead of taking $1$ unit off $n-1$ elements, add $1$ to all the elements of the array and subtract $1$ from only one element. This algorithm is the same as the second algorithm. It keeps the relative difference between elements, but they are a shifted version of what is done in the second algorithm. So, if you find an optimum sequence of operations for one algorithm, then the same sequence is applicable to the other algorithm.