```
func minMoves(_ nums: [Int]) -> Int {
var min = nums.first!
var sum = 0
for num in nums {
sum += num
if num < min {
min = num
}
}
return sum - ((nums.count-1)*min) - min
}
```