You are given an array of integers.
For a positive integer , you may perform the following operation any number of times:
Choose two indices and such that and . Then decrease by and increase by .
Find the maximum integer with such that it is possible to make every element of the array equal to .
If there is no such integer , output .
Choosing indices and once changes the array to . Since cannot be larger than , the maximum possible value is .
The only possible operation would decrease the first element and increase the second element, so it cannot make the array equal to .
For , choosing once and twice makes all elements equal to . For , the third position cannot receive a unit from any position far enough to its left.
The array is already all zero, so every from to is valid. The maximum one is .