```
public class Solution {
public int minMoves(int[] nums) {
int sum = 0;
Arrays.sort(nums);
for(int i=nums.length-1;i>0;i--){
int diff = nums[i] -nums[0];
sum += diff;
for(int j=i-1;j>=0;j--)
nums[j] += diff;
}
return sum;
}
}
```