We need to find smallest integer k >= max(a_i) such that total votes for Awruk > total votes for Elodreip. Awruk gets (k - a_i) from each student i. So total Awruk = nk - sum(a_i). Elodreip total = sum(a_i). Condition: nk - sum(a_i) > sum(a_i) => nk > 2sum(a_i) => k > 2*sum(a_i)/n.
We need k integer, k >= max(a_i), and also k > 2*S/n. Since k must be strictly greater, we need minimal integer k satisfying both.
Thus compute S = sum(a_i). Compute threshold T = 2*S/n. We need k > T. So minimal integer k is floor(T)+1, but also must be >= max_a.
Therefore answer = max( max_a, floor(2S/n) + 1). However careful: if 2S/n is integer, say 2*S/n = m, then need k > m, so k >= m+1. So formula holds.
But also need to ensure that k is integer. Since S and n are integers, 2S may not be divisible by n. So floor(2S/n) = integer division (floor). So candidate k0 = floor(2*S/n) + 1. Then answer = max(max_a, k0). Also check condition: ensure that with this k, Awruk gets strictly more? Yes.
Double-check: nk > 2S. If we take k = max(max_a, floor(2S/n)+1), then we guarantee nk > 2S? Possibly if k = max_a but max_a could be > floor+1? Actually if max_a > floor+1, then we need to verify that nmax_a > 2S? It may not hold if max_a is larger but still less than threshold? Wait: Suppose max_a is large, but floor+1 might be smaller. But if max_a is chosen, we need to ensure nmax_a > 2S. However it's not guaranteed that just because max_a >= floor+1 that nmax_a > 2S. Example: n=2, a = [3,5]. Then max_a=5, S=8, 2S/n = 8, floor=8, floor+1=9. So candidate k0=9. max_a=5 <9, so answer=9. But if max_a=10? Let's try a scenario: n=3, a=[10,10,10] => max_a=10, S=30, 2S/n=20, floor+1=21. So answer=21, but if max_a=21? Not possible because max_a <= 100, but anyway. If we artificially set a = [100,1,1]? n=3, max_a=100, S=102, 2S/n=68, floor+1=69. So answer=100? But 100 >69, so answer=100. Does n100 > 2S? 300 > 204, yes. So it's fine. Actually if max_a is greater than floor+1, it's definitely > threshold? Not necessarily: Consider n=2, a=[5,5] => max_a=5, S=10, 2S/n=10, floor+1=11. max_a=5 <11. If max_a=10? But max_a can't exceed a_i? Actually a_i are given, so max_a is the maximum among a_i. If max_a is larger than floor+1, then max_a >= floor+2. Then nmax_a >= n*(floor+2) = nfloor+2n. Since floor = floor(2S/n), we have floor <= 2S/n < floor+1. So nfloor <= 2S. Then nmax_a >= nfloor+2n > 2S + (2n - (2S - nfloor)). But 2S - nfloor is the remainder r (0 <= r < n). So nmax_a >= 2S + (2n - r). Since n>=1, 2n - r >0 for n>=1? Let's check: r < n, so 2n - r > n >=1. So indeed nmax_a > 2S. So yes, if max_a >= floor+2, it's automatically > threshold. But what if max_a = floor+1? That's exactly floor+1, which is the candidate. So it's also > threshold. So max(max_a, floor+1) works because if max_a > floor+1 then condition holds, as argued? Let's be rigorous: If k = max_a and max_a > floor(2S/n)+1, then since max_a is integer, max_a >= floor(2S/n)+2. Then nk >= n(floor+2) = nfloor + 2n. Since nfloor <= 2S (since floor <= 2S/n, so nfloor <= 2S). Actually 2S/n >= floor, so nfloor <= 2S. Thus nk >= nfloor + 2n > 2S because nfloor <= 2S and 2n >0. But we need strict >, but if nfloor may be exactly 2S? Could be if 2S is divisible by n. Then floor = 2S/n exactly. Then n*k >= 2S+2n >2S. So yes. So condition satisfied. Therefore answer = max(max_a, floor(2S/n)+1) yields correct minimal k. But also note the problem constraint: k >= max_a, so if floor+1 < max_a, then answer = max_a, which is minimal possible k meeting the >= max_a condition. But must also satisfy winning condition; we argued it does. So correct.
Edge cases: n=1. Then we have a1. Need k >= a1 and such that Awruk votes > Elodreip: 1*k - a1 > a1 => k > 2a1 => k >= 2a1+1? Actually k > 2a1, so minimal integer k = 2a1+1. But also k >= a1. So answer = max(a1, 2a1+1) = 2a1+1. Our formula: S=a1, 2S/n = 2a1, floor(2S/n) = 2a1 (since integer), floor+1 = 2a1+1. max_a = a1, so answer = max(a1, 2a1+1) = 2a1+1. Works.
Now implement: read n, list a. Compute max_a = max(a), S = sum(a). Compute threshold = (2S) // n? Actually floor(2S/n) is integer division but careful: Python integer division // floors downwards, but for positive numbers it's floor. So floor = (2S) // n. But if 2*S is not divisible by n, this yields floor. Then candidate = floor + 1. Answer = max(max_a, candidate). However, what if candidate already satisfies condition? It does by construction. But double-check: If 2S is divisible by n, then floor = 2S/n, candidate = 2S/n +1, which yields >. Good.
But consider scenario: n=2, a=[1,2]. S=3, 2S=6, 6/2=3 exactly. floor=3, candidate=4. max_a=2. answer=4. Check: k=4: Awruk votes: (4-1)+(4-2)=3+2=5, Elodreip=3 -> 5>3, win. k=3? max_a=2 <3, but k=3 yields Awruk=(3-1)+(3-2)=2+1=3, tie 3=3 not win. So 4 is minimal. Correct.
Now scenario: n=3, a=[2,2,2]. S=6, 2S=12, 12/3=4 exactly, candidate=5, max_a=2, answer=5. Check: k=5 => Awruk sum= (35)-6=15-6=9, Elodreip=6, win. k=4? 12-6=6, tie not win. k=3? but k must be >= max_a=2, but also >=max_a? Actually k must be >= max_a, so k=3 is allowed but < candidate? Check: 33-6=9-6=3, Elodreip=6? Wait compute: n*k - S = 9-6=3, Elodreip=6, 3<6, lose. So k=4 gives tie, not win. So 5 minimal.
Thus solution is straightforward.
But wait: The problem states: "Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds." That means k must be at least each a_i to ensure non-negative votes for Awruk. That's why k >= max(a_i). So correct.
Thus algorithm: O(n) time.
Now implement solve().
We'll read input from standard input. Output answer.
Testing with examples: Example1: n=5, a=[1,1,1,5,1] => max_a=5, S=9, 2S=18, 18/5=3.6 floor=3 candidate=4, max(5,4)=5. Output 5. Example2: n=5, a=[2,2,3,2,2] => max_a=3, S=11, 2S=22, 22/5=4.4 floor=4 candidate=5, max(3,5)=5. Output 5.
Edge: n=100, all a_i=100 => max_a=100, S=10000, 2S=20000, /100=200, candidate=201, answer=201. Check: Awruk votes=100*201-10000=20100-10000=10100 >10000? Actually Elodreip=10000, Awruk=10100, win. k=200 would give tie: 20000-10000=10000 tie.
Works.
But wait: Could there be any scenario where candidate computed as floor(2S/n)+1 is less than max_a but max_a fails to satisfy the condition? No, we argued it does. But need to double-check edge case: Suppose n=1, we already did. Suppose n=2, a=[0,0]? But a_i are at least 1 according to constraints? The input constraints say 1 ≤ a_i ≤ 100, so a_i >=1, so no zeros. But even if zeros, our reasoning holds: k must be >= max_a, which could be 0? But constraints say min 1.
Another nuance: The condition for victory is strict >. So formula stands.
Thus code is simple.
But before writing final, consider if we need to check that k must be integer, it is.
Potential pitfalls: For large numbers? n up to 100, a_i up to 100, sum up to 10000, 2S up to 20000, division fine.
One more check: The derived condition is nk > 2S. Since k integer, minimal k > 2S/n. So answer = max( max_a, floor(2S/n) + 1). That's it.
But maybe there's a twist: Each student gives a_i votes to Elodreip, and they will give exactly k - a_i to Awruk. But we assumed that the votes are integer, which they are. So fine.
Thus solution.
But let's read problem statement again: "He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections." Actually, he wants to change the number k? The original k is presumably something else, but he can choose a new k? He can change it. But the problem asks: "Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory." So we output that.
Thus final code.
Implementation:
def solve():
import sys
data = sys.stdin.read().strip().split()
if not data: return
n = int(data[0])
a = list(map(int, data[1:]))
max_a = max(a)
total = sum(a)
# minimal k > 2total/n
# compute floor(2total/n) using integer division
need = (2 * total) // n
# if 2total is exactly divisible by n, then need is exactly 2total/n, but we need >, so need+1
# but careful: if (2total) % n == 0, then need = 2total/n, then need+1 works.
# However, integer division floor for positive numbers gives floor, so need may be less than 2total/n if not divisible.
# So candidate = need + 1 always works? Check: Suppose 2total/n = 4.2, need = 4, need+1=5 > 4.2, good.
# If 2total/n = 4, need =4, need+1=5 >4, good. So candidate = need + 1 works.
candidate = need + 1
# but wait: There is a nuance: If 2total/n is not an integer, need = floor, need+1 is ceil. But we need >, not >=. Since need+1 is > floor, and floor < actual value < floor+1, need+1 > actual value. So yes.
ans = max(max_a, candidate)
print(ans)
But is there any scenario where candidate computed as need+1 is not sufficient because of integer rounding? Let's test with n=2, total=3: 2*total/n=3, need=3, candidate=4, we need k >3, so 4 works. Fine.
Now consider scenario where candidate is less than max_a, we take max_a, and we need to ensure max_a > 2total/n? As argued, if max_a >= candidate+1? Actually we need to ensure that the chosen k (max_a) satisfies nk > 2total. Let's test a borderline scenario: Suppose n=2, a=[1,3] => max_a=3, total=4, 2total/n =8/2=4, need=4, candidate=5. max_a=3 <5, so ans=5. That's fine. But if max_a=5? Let's try: a=[1,5]? max_a=5, total=6, 2*total/n=12/2=6, need=6, candidate=7, ans=7. So max_a=5 is less than candidate, so ans=7. That scenario doesn't test the case where max_a > candidate.
Now try to construct where max_a > candidate: need small. Since candidate = floor(2S/n)+1. max_a is at most 100, S up to 10000. Let's find values: n=100, all a_i=1 except one is 100. Then max_a=100, total=991+100=199? Actually 991+100=199, S=199, 2S=398, /100=3.98, floor=3, candidate=4. So ans = max(100,4)=100. Check condition: nk=100100=10000, 2S=398, 10000 > 398 obviously. So win. So fine.
But is there any scenario where max_a > candidate but nmax_a <= 2S? That would be a problem. Let's try to see if max_a > candidate but nmax_a <= 2S. Since candidate = floor(2S/n)+1. So max_a > floor(2S/n)+1 means max_a >= floor(2S/n)+2. Then nmax_a >= n(floor(2S/n)+2) = nfloor(2S/n) + 2n. Now nfloor(2S/n) <= 2S, but could be less. The worst case: nfloor(2S/n) could be as low as 2S - (n-1) because floor(2S/n) = (2S - r)/n where r = 2S mod n, 0 <= r < n. So nfloor = 2S - r. Then nmax_a >= 2S - r + 2n = 2S + (2n - r). Since r < n, 2n - r > n > 0, so nmax_a > 2S. So condition satisfied. So indeed if max_a >= floor+2, then nmax_a > 2S. If max_a = floor+1 exactly, then max_a = candidate, and nmax_a = n*(floor+1) = nfloor + n. Since nfloor <= 2S and we need >2S, we need nfloor + n > 2S => n > 2S - nfloor = r. Since r < n, indeed n > r holds (since n >=1 and r < n). But careful: if r = 0 (exact division), then nfloor = 2S, so nmax_a = 2S + n > 2S, so condition holds. If r > 0, then nfloor = 2S - r, so nmax_a = 2S - r + n. This > 2S iff n > r, which is true because r < n. So also holds. Therefore, max_a = candidate always yields n*max_a > 2S. So our answer works.
Thus solution correct.
Now, implement in Python.
But maybe there's another nuance: The problem says "Each student has exactly k votes and is obligated to use all of them." That means each student must allocate all k votes between the two candidates? Actually, the phrasing: "He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds." So yes, each student splits his k votes between the two candidates, giving a_i to Elodreip and the rest to Awruk. So total votes for Awruk is sum(k - a_i) = nk - sum(a_i). And total votes for Elodreip is sum(a_i). Condition for win: nk - sum(a_i) > sum(a_i) => nk > 2sum(a_i). Good.
Now note: The constraint k >= max(a_i) ensures that k - a_i >= 0 for each student, which is necessary.
Thus final answer.
We should also consider that the input might have extra spaces, etc. So reading with sys.stdin is fine.
We'll produce code accordingly.
Now test with some random values to ensure.
Edge case: n=1, a=1 -> total=1, 2*total/n=2, candidate=3, max_a=1, ans=3. Check: k=3: Awruk votes=3-1=2, Elodreip=1 -> 2>1 win. k=2: 2-1=1, tie not win. So 3 minimal.
Another: n=1, a=100 -> ans = 201.
Edge: n=2, a=[100,100] -> total=200, 2total/n=400/2=200, candidate=201, max_a=100, ans=201. Check: k=201 => Awruk=2201-200=202, Elodreip=200 -> win.
Now confirm that answer cannot be less than max_a, as required.
Now code.
One more thought: Could there be a scenario where the computed candidate is less than max_a but the condition is not satisfied for k = max_a? As argued, it always is because if max_a >= candidate, it's either equal or greater. Both cases we proved work. So fine.
Thus final solution.
Now I'll write the final answer.
```python
import sys
def solve() -> None:
data = sys.stdin.read().strip().split()
if not data:
return
n = int(data[0])
a = list(map(int, data[1:]))
max_a = max(a)
total = sum(a)
# smallest integer > 2*total/n
need = (2 * total) // n # floor
candidate = need + 1
ans = max(max_a, candidate)
print(ans)
if name == "main":
solve()