class Solution:
    def minMoves(self, nums: List[int]) -> int:
        return sum(nums)-min(nums)*len(nums)
class Solution {
    public int minMoves(int[] nums) {
        int min=Integer.MAX_VALUE;
        int count=0;
        for(int i:nums)
            min=Math.min(i,min);
        
        for(int i=0;i<nums.length;i++)
        {
            count+=nums[i]-min;
        }
        return count;
    }
}
Minimum Moves to Equal Array Elements
Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

In one move, you can increment n - 1 elements of the array by 1.

&nbsp;
Example 1:

Input: nums = [1,2,3]
Output: 3
Explanation: Only three moves are needed (remember each move increments two elements):
[1,2,3]  =&gt;  [2,3,3]  =&gt;  [3,4,3]  =&gt;  [4,4,4]


Example 2:

Input: nums = [1,1,1]
Output: 0


&nbsp;
Constraints:


	n == nums.length
	1 &lt;= nums.length &lt;= 105
	-109 &lt;= nums[i] &lt;= 109
	The answer is guaranteed to fit in a 32-bit integer.


var minMoves = function(nums) {
    let minElm = Math.min(...nums);
    let ans = 0;
    for(let i=0; i<nums.length; i++){
        ans += (nums[i]-minElm)
    }
    return ans
};
class Solution {
public:
    int minMoves(vector<int>& nums) {

        // sorting the array to get min at the first
        sort(nums.begin(), nums.end());
        int cnt = 0, n = nums.size();

        // Now we have to make min equal to every number and keep adding the count
        for(int i = 1; i < n; i++)
            cnt += nums[i] - nums[0];

        return cnt;
    }
};