```
public class Solution {
public int minMoves(int[] a) {
int min = Integer.MAX_VALUE;
int minIndex = 0;
for(int i = 0 ; i < a.length ; i ++){
if(a[i] < min) {
min = a[i];
minIndex = i;
}
}
int sum = 0 ;
for(int i = 0 ; i < a.length ; i ++) {
if(i == minIndex) {
continue ;
}
sum = sum + (a[i] - min) ;
}
return sum;
}
}
```