Please look at the discussion https://discuss.leetcode.com/topic/66737/it-is-a-math-question to understand how to figure out the equation mathematically.

```
public int minMoves(int[] nums) {
if(nums.length==0) {
return 0;
}
int sum=0;
int min=Integer.MAX_VALUE;
for(int i=0;i<nums.length;i++) {
min = Math.min(min,nums[i]);
sum += nums[i];
}
return (sum-(min*nums.length));
}
```