For any given array {x_{i=1:N}}, the answer is simply Σ_{i=1:N} x_{i=1:N} - N*x_{min}, where x_{min} is the min of the array.

**Proof:** it is clearly that the solution to this problem only depends on the relative differences between entries of {x_{i=1:N}}, i.e.,

- Solution to array {x
_{i=1:N}} is same as solution to {x_{i=1:N}+ C}, where C is arbitrary constant.

Therefore, incrementing N-1 entries by 1 is equivalent to decrementing the left over entry by 1. So the answer will be how many decrements it takes to decrease all x_{i=1:N} to a same value. Apparently, the minimum is to decrease every entry to x_{min}, so

- ans = Σ
_{i=1:N}(x_{i=1:N}- x_{min}) = Σ_{i=1:N}x_{i=1:N}- N*x_{min}.

```
int minMoves(vector<int>& nums) {
int minx = INT_MAX, sum = 0;
for (int x:nums) { sum += x; minx = min(minx, x); }
return sum - minx*nums.size();
}
```