Calculate the total number of dresses and check if it's divisible by the number of machines.
If not divisible, return -1.
Calculate the average number of dresses per machine.
Create a gain/loss array where each element is the number of dresses the machine needs to give away (negative) or receive (positive) to reach the average.
Initialize variables for the running sum and the maximum moves required.
Iterate through the gain/loss array, updating the running sum and the maximum moves required.
The maximum moves required is the maximum of the absolute running sum and the individual gain/loss at each machine.