#P5817. [CQOI2011] 分金币
[CQOI2011] 分金币
Description
There are people sitting around a round table. Each person has some number of gold coins, and the total number of coins is divisible by . Each person can give some coins to their left and right neighbors, and in the end everyone must have the same number of coins.
Your task is to find the minimum total number of coins that are passed from hand to hand.
Input Format
The first line contains an integer ().
The next lines each contain a positive integer, given in counterclockwise order, representing the number of coins each person has.
Output Format
Output one line containing the minimum total number of coins that are passed from hand to hand.
4
1
2
5
4
4
Hint
Sample Explanation
Suppose the four people are numbered . Person gives person coins (becoming ). Then person and person each give person coin.
Constraints
For of the testdata, , and .
Translated by ChatGPT 5
京公网安备 11011102002149号