Defective Script
시간 제한2초메모리 제한2048 MB
원형으로 배치된 서버 부하에서 한 서버를 고르면 그 서버는 2만큼, 이전 서버는 1만큼 줄어든다. 모든 서버를 같게 만들 수 있는 최대 부하를 구한다.
문제
Devin is a system administrator at a tech company that manages a network of servers arranged in a ring topology. Each server is handling a certain amount of computational load, represented by a non-negative integer , where ranges from to .
To optimize the network performance and ensure fairness, Devin wants to equalize the load across all servers, making each server handle the same amount of load. He aims to maximize this equal load as much as possible.
Devin has developed a script to reduce the load on any server. When he runs the script on server , it is supposed to decrease the load on that server by units (down to a minimum of zero). However, due to a known bug in the script, every time it's executed on server , it inadvertently removes an additional unit of load from the previous server in the network (server ). If , the previous server is server (since the servers form a ring).
Devin can run this buggy script any number of times (including zero), each time choosing any server to run it on. He can run the script on a server even if its current load is less than units, or if the load of the previous server is zero (in both cases the load goes to zero).
Help Devin determine the maximum possible equal load that can be achieved on all servers using his script.
입력
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of servers ().
The second line contains integers , denoting the amounts of load the servers are handling ().
It is guaranteed that the sum of over all test cases does not exceed .
출력
For each test case, print the maximum possible equal load that can be achieved on all servers.
힌트
In the first test case, Devin can run the script once on server , twice on server , and once on server . As a result, each server will be handling units of load.