There are $n$ block towers, numbered from $1$ to $n$. The $i$-th tower consists of $a_i$ blocks.

In one move, you can move one block from tower $i$ to tower $j$, but only if $a_i > a_j$. That move increases $a_j$ by $1$ and decreases $a_i$ by $1$. You can perform as many moves as you would like (possibly, zero).

What's the largest amount of blocks you can have on the tower $1$ after the moves?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of testcases.

The first line of each testcase contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of towers.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the number of blocks on each tower.

The sum of $n$ over all testcases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each testcase, print the largest amount of blocks you can have on the tower $1$ after you make any number of moves (possibly, zero).


-----Examples-----

Input
4
3
1 2 3
3
1 2 2
2
1 1000000000
10
3 8 6 7 4 1 2 4 10 1
Output
3
2
500000001
9


-----Note-----

In the first testcase, you can move a block from tower $2$ to tower $1$, making the block counts $[2, 1, 3]$. Then move a block from tower $3$ to tower $1$, making the block counts $[3, 1, 2]$. Tower $1$ has $3$ blocks in it, and you can't obtain a larger amount.

In the second testcase, you can move a block from any of towers $2$ or $3$ to tower $1$, so that it has $2$ blocks in it.

In the third testcase, you can $500000000$ times move a block from tower $2$ to tower $1$. After that the block countes will be $[500000001, 500000000]$.

Difficulty: EASY

Solutions:
import sys
rd = sys.stdin.readline
for _ in range(int(rd())):
	n = int(rd())
	a = list(map(int, rd().split()))
	b = sorted(a[1:])
	ans = a[0]
	for i in b:
		if i > ans:
			ans = (ans + i + 1) // 2
	print(ans)


import sys
from os import path, chdir

def input():
	return sys.stdin.readline().strip()

def solve(n, a):
	if max(a) == a[0]:
		print(a[0])
		return
	t = a[0]
	s = sorted(a[1:])
	for e in s:
		if e > t:
			d = (1 + e - t) // 2
			t += d
	print(t)

def main():
	testcases = int(input())
	for _ in range(testcases):
		n = int(input())
		array = list(map(int, input().split()))
		solve(n, array)
main()


import sys, math, heapq, bisect, random, itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)
ints = lambda : list(map(int, input().split()))
p = 10 ** 9 + 7
inf = 10 ** 20 + 7
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for t in range(int(input())):
	n = int(input())
	a = ints()
	x = a[0]
	b = sorted(a[1:])
	for i in b:
		if i > x:
			c = i - x
			x += (c + 1) // 2
	print(x)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(N, A) = (int(input()), list(map(int, input().split())))
	B = A[1:]
	B.sort()
	ans = A[0]
	for i in B:
		if ans < i:
			ans = (ans + i + 1) // 2
	print(ans)


import sys
import heapq, bisect, math
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import permutations, combinations
from functools import lru_cache
import math
input = lambda : sys.stdin.readline().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
inf = 2 ** 63 - 1
mod = 10 ** 9 + 7
X = [0, 1, 0, -1, -1, 1, -1, 1]
Y = [1, 0, -1, 0, -1, 1, 1, -1]

def euclidean_algorithm(a, b):
	while b != 0:
		r = a % b
		a = b
		b = r
	return a

def solve():
	n = ii()
	l = li()
	out = l[0]
	l = l[1:]
	l.sort()
	l = [out] + l
	for i in range(1, n):
		if out < l[i]:
			out += (l[i] - out + 1) // 2
	print(out)
for _ in range(ii()):
	solve()


import math

def f():
	lst = []
	for j in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		temp = sorted(a[1:n])
		for i in temp:
			if i > a[0]:
				a[0] += (i - a[0] + 1) // 2
		lst.append(a[0])
	print(*lst, sep='\n')
f()


import sys
input = sys.stdin.readline

def readList():
	return list(map(int, input().split()))

def readInt():
	return int(input())

def readInts():
	return map(int, input().split())

def readStr():
	return input().strip()

def solve():
	n = readInt()
	arr = readList()
	curr = arr[0]
	arr = [arr[0]] + sorted(arr[1:])
	for i in range(1, n):
		if curr < arr[i]:
			curr = (curr + arr[i] + 1) // 2
	return curr
for _ in range(int(input())):
	print(solve())


import sys

def solve():
	inp = sys.stdin.readline
	n = int(inp())
	a = list(map(int, inp().split()))
	first = a.pop(0)
	a.sort()
	for v in a:
		if v > first:
			x = (v - first - 1) // 2
			if x > 0:
				v -= x
				first += x
			if v > first:
				v -= 1
				first += 1
	print(first)

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	one = arr[0]
	arr.pop(0)
	curr = one
	arr.sort()
	for (i, z) in enumerate(arr):
		if z > curr:
			diff = z - curr
			curr += (diff + 1) // 2
	return curr
for _ in range(int(input())):
	print(main())


import math
import sys
input = sys.stdin.readline

def problem_b():
	n = int(input())
	a = list(map(int, input().split()))
	val = a[0]
	a = a[1:]
	a.sort()
	for j in range(n - 1):
		if a[j] > val:
			diff = (a[j] - val) // 2
			if (a[j] - val) % 2 == 1:
				val += 1
			val += diff
	return val

def main():
	for _ in range(int(input())):
		rez = problem_b()
		print(rez)
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	input()
	a = list(map(int, input().split()))
	t1 = a[0]
	del a[0]
	a.sort()
	for i in a:
		if i <= t1:
			continue
		t1 = t1 + i - (t1 + i) // 2
	print(t1)


from math import ceil
import sys
input = sys.stdin.readline
inp = sys.stdin.readline

def input():
	return inp().strip()

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def solve():
	n = ii()
	arr = li()
	first = arr[0]
	na = []
	prev = first
	for i in arr[1:]:
		if prev < i:
			na.append(i)
	na.sort()
	na = [first] + na
	for i in na:
		if na[0] < i:
			na[0] += (i - na[0] + 1) // 2
	print(na[0])

def main():
	for _ in range(ii()):
		solve()
main()


for s in [*open(0)][2::2]:
	(b, *a) = map(int, s.split())
	for x in sorted(a):
		b += max(0, x - b + 1) // 2
	print(b)


import math
test = int(input())
result = []
for i in range(test):
	input()
	[first, *b] = list(map(int, input().split(' ')))
	b.sort()
	for j in b:
		if j > first:
			first += math.ceil((j - first) / 2)
	result.append(first)
[print(i) for i in result]


t = int(input())
result = []
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split(' ')))
	nb = ai[0]
	si = ai[1:]
	si.sort()
	for j in range(n - 1):
		if si[j] > nb:
			bl = si[j] - (nb + si[j]) // 2
			nb += bl
	result.append(nb)
for i in result:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = a[0]
	a = sorted(a[1:])
	for y in a:
		if y > x:
			x += (y - x + 1) // 2
	print(x)


import math
T = int(input())
output = []
while T > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a1 = a[0]
	a = sorted(a)
	index = a.index(a1)
	b = a[index + 1:len(a)]
	for x in b:
		a1 = math.ceil((a1 + x) / 2)
	output.append(a1)
	T -= 1
for i in output:
	print(i)


t = int(input())

def quick_sort(array, left, right):
	if left >= right:
		return
	low = left
	high = right
	key = array[low]
	while left < right:
		while left < right and array[right] > key:
			right -= 1
		array[left] = array[right]
		while left < right and array[left] <= key:
			left += 1
		array[right] = array[left]
	array[right] = key
	quick_sort(array, low, left - 1)
	quick_sort(array, left + 1, high)

def run():
	n = int(input())
	lst = list(map(int, input().split()))
	mid = lst.pop(0)
	lst.sort()
	for i in lst:
		if mid < i:
			mid = (mid + i + 1) // 2
	print(mid)
while t:
	t -= 1
	run()


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[0]
	a.remove(a[0])
	a.sort()
	for i in range(len(a)):
		if a[i] > b:
			b += math.ceil((a[i] - b) / 2)
	print(b)


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	vls = sorted(ar[1:])
	v = ar[0]
	for e in vls:
		if e > v:
			sm = (e + v + 1) // 2
			v = sm
	print(v)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	curr = arr[0]
	arr.pop(0)
	arr.sort()
	for i in arr:
		if i > curr:
			curr = (curr + i + 1) // 2
	print(curr)


import sys
input = sys.stdin.readline
import math
T = int(input())
for _ in range(T):
	n = int(input())
	lst = list(map(int, input().split()))
	T1 = lst[0]
	lst = lst[1:]
	lst.sort()
	low = 0
	for j in range(len(lst)):
		if lst[j] > T1:
			low = j
			break
	lst = lst[low:]
	for i in range(len(lst)):
		if lst[i] > T1:
			T1 = math.ceil((T1 + lst[i]) / 2)
	print(T1)


import math
import collections
import bisect
import heapq
from collections import deque
from math import sqrt, ceil, floor

def inp_arr():
	return list(map(int, input().strip().split(' ')))

def inp_str_arr():
	return list(input().strip().split(' '))

def inp_str():
	return input()

def solve():
	(n,) = inp_arr()
	a = inp_arr()
	ans = a[0]
	b = a[1:n]
	b.sort()
	for i in range(0, n - 1):
		diff = b[i] - ans
		if diff > 0:
			ans += (diff + 1) // 2
	print(ans)
(tt,) = inp_arr()
for t in range(tt):
	solve()


def solve():
	n = int(input())
	lis = list(map(int, input().split()))
	ele = lis[0]
	lis = sorted(lis[1:])
	for i in lis:
		if i > ele:
			cur_val = i - ele + 1
			cur_val //= 2
			ele += cur_val
	print(ele)
for _ in range(int(input())):
	solve()


def solve(xs):
	y = next(xs)
	for x in sorted(xs):
		if x > y:
			y += (x - y + 1) // 2
	return y
t = int(input())
for _ in range(t):
	_ = input()
	xs = map(int, input().split(' '))
	print(solve(xs))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	first = l[0]
	l = sorted(l[1:])
	for x in l:
		if x > first:
			first += (x - first + 1) // 2
	print(first)


def solve():
	n = int(input())
	arr = [int(i) for i in input().split()]
	x = arr[0]
	for i in sorted(arr[1:]):
		if x < i:
			x += (i - x + 1) // 2
	print(x)
tst = int(input())
for i in range(tst):
	solve()


def BlockTower(tower: list):
	tower = [int(value) for value in tower]
	sortedTowers = sorted(tower[1:])
	for value in sortedTowers:
		if tower[0] < value:
			tower[0] += (value - tower[0] + 1) // 2
	print(tower[0])
testcases = int(input())
towers = []
for _ in range(testcases):
	length = int(input())
	towers.append(input().split(' ')[:length])
for tower in towers:
	BlockTower(tower)


for __ in range(int(input())):
	n = int(input())
	(a, *b) = map(int, input().split())
	b.sort()
	for x in b:
		if x > a:
			a += (x - a + 1) // 2
	print(a)


from typing import List
from bisect import *
from collections import *
from functools import *
from itertools import *
from math import *
from queue import PriorityQueue
INF = 2 ** 64 - 1
MOD = 10 ** 9 + 7
mi = lambda : map(int, input().split())
li = lambda : list(mi())

def main(n, nums):
	ans = nums[0]
	srcNum = nums[1:]
	srcNum.sort()
	for v in srcNum:
		if v > ans:
			ans = ans + (v - ans + 1) // 2
	print(ans)
	return
caseNum = int(input())
for i in range(0, caseNum):
	n = int(input())
	nums = li()
	main(n, nums)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = a[0]
	a = a[1:n]
	a.sort()
	for i in range(n - 1):
		if a[i] > x:
			x = (a[i] + x + 1) // 2
	print(x)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(a[1:])
	for i in b:
		if i > a[0]:
			a[0] = (a[0] + i + 1) // 2
	print(a[0])


def f(a: list, n: int) -> list:
	_answ = a[0]
	a = a[1:]
	a.sort()
	for i in a:
		if _answ < i:
			_answ = (_answ + i + 1) // 2
	return _answ
for _ in range(int(input())):
	n: int = int(input())
	a = list(map(int, input().strip().split()))
	print(f(a, n))


def oi():
	return int(input())

def ti():
	return map(int, input().split())

def mi():
	return list(map(int, input().split()))

def ceildiv(a, b):
	return -(a // -b)

def solve():
	n = oi()
	a = mi()
	ans = a[0]
	a = a[1:]
	a.sort()
	for i in a:
		if ans < i:
			ans = ceildiv(ans + i, 2)
	print(ans)
for _ in range(oi()):
	solve()


import sys
import math
from bisect import bisect_right as br
from collections import deque, Counter
from itertools import combinations as cb
from collections import deque

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	ans = arr[0]
	arr[0] = -1
	arr.sort()
	i = 1
	while i < n:
		if ans >= arr[i]:
			i += 1
			continue
		ans = math.ceil((ans + arr[i]) / 2)
		i += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	f = nums[0]
	nums = nums[1:]
	nums.sort()
	for num in nums:
		if f < num:
			f = (num + f + 1) // 2
	print(f)


from collections import defaultdict
from sys import stdin, stdout
import string
import math

def solution(N, A):
	first = A[0]
	sorted_a = sorted(A)
	for i in range(1, len(A)):
		if first >= sorted_a[i]:
			continue
		first += math.ceil((sorted_a[i] - first) / 2)
	return f'{first}'
test_cases = int(stdin.readline())
for it in range(test_cases):
	N = int(stdin.readline())
	A = list(map(int, list(stdin.readline().split())))
	print(solution(N, A))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	a = s[0]
	s_ = s[1:]
	s_.sort()
	for i in s_:
		if i > a:
			a = (a + i + 1) // 2
	print(a)


u = int(input())
h1 = []
for tttttt in range(u):
	i = input()
	g = [int(a) for a in input().split()]
	g1 = g[0]
	g.pop(0)
	g = sorted(g)
	for eee in range(len(g)):
		if g1 < g[eee]:
			if g1 % 2 == g[eee] % 2:
				g1 += (g[eee] - g1) // 2
			else:
				g1 += (g[eee] - g1) // 2 + 1
	h1.append(g1)
[print(ff) for ff in h1]


import math
b = int(input())
a = []

def ans(n, l):
	t = l[0]
	l = l[1:n]
	l.sort()
	for j in range(n - 1):
		if t < l[j]:
			tmp = math.ceil(float(l[j] - t) / 2)
			t = t + tmp
	return t
for i in range(b):
	n = int(input())
	l = list(map(int, input().strip().split()))
	a.append(ans(n, l))
for x in a:
	print(x)


t = int(input())
for _ in range(t):
	n = int(input())
	lst = [int(i) for i in input().split()]
	elem = lst[0]
	lst.sort()
	for i in lst:
		if i > elem:
			if (i + elem) % 2 == 0:
				elem = (i + elem) // 2
			else:
				elem = (i + elem) // 2 + 1
	print(elem)


testcases = int(input())
for i in range(testcases):
	number_of_towers = int(input())
	blocks_in_towers = [int(i) for i in input().split()]
	block_in_tower_1 = blocks_in_towers[0]
	blocks_in_towers = sorted(blocks_in_towers[1:])
	for x in blocks_in_towers:
		if x > block_in_tower_1:
			block_in_tower_1 = block_in_tower_1 + (x - block_in_tower_1 + 1) // 2
	print(block_in_tower_1)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst_z = lst[0]
	lst.sort()
	ans = lst[1:]
	for i in ans:
		if i > lst_z:
			lst_z += (i - lst_z + 1) // 2
	print(lst_z)


import math

def ans(n, a):
	h = a[0]
	k = []
	for i in range(n):
		if a[i] >= h:
			k.append(a[i])
	r = h
	k = sorted(k)
	for i in range(len(k)):
		if k[i] > r:
			r = math.ceil((r + k[i]) / 2)
	return r
t = int(input())
l = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l.append(ans(n, a))
for i in range(t):
	print(l[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	one = a[0]
	a = sorted(a[1:])
	for j in a:
		if j > one:
			one += (j - one + 1) // 2
	print(one)


import math
inputs = []
for i in range(int(input())):
	new_input_len = int(input())
	new_input = input().split(' ')
	new_input = [int(x) for x in new_input]
	inputs.append(new_input)
for i in range(len(inputs)):
	(first, rest) = (inputs[i][0], inputs[i][1:])
	rest = list(sorted(rest))
	for ele in rest:
		if ele > first:
			first += math.floor((ele - first + 1) / 2)
	print(first)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	first = a.pop(0)
	a = sorted((x for x in a if x > first))
	for num in a:
		first += (num - first + 1) // 2
	print(first)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = l[0]
	l = sorted(l[1:])
	for y in l:
		if y > x:
			x += (y - x + 1) // 2
	print(x)


num_test_cases = int(input())
for _ in range(num_test_cases):
	n = int(input())
	arr = list(map(int, input().split()))
	first = arr.pop(0)
	arr.sort()
	for num in arr:
		if num > first:
			first = (num + first + 1) // 2
	print(first)


import math
n = int(input())
ans = []
for _ in range(n):
	m = int(input())
	l = list(map(int, input().split()))
	new_l = l[1:]
	f = l[0]
	new_l.sort()
	for i in range(len(new_l)):
		if new_l[i] > f:
			f += math.ceil((new_l[i] - f) / 2)
	ans.append(f)
for j in ans:
	print(j)


import sys
import re
import math
from math import log2
from math import log
from math import ceil
from math import gcd
from decimal import *
from datetime import date
from collections import deque
import random
import heapq
import itertools
import datetime
const = 1000000007
ep = 1e-08

def get():
	return list(map(int, input().split()))
n = int(input())
for i in range(n):
	m = int(input())
	line = get()
	temp = line[1:]
	temp.sort()
	for term in temp:
		if term > line[0]:
			line[0] = (term + line[0] + 1) // 2
	print(line[0])


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split()]
	a1 = nums[0]
	nums = nums[1:]
	nums.sort()
	for num in nums:
		if num > a1:
			a1 += ceil((num - a1) / 2)
	print(a1)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	aa = [int(ii) for ii in input().split()]
	a = aa[0]
	b = aa[1:]
	b.sort()
	for i in range(n - 1):
		if b[i] > a:
			a = (a + b[i] + 1) // 2
	print(a)


def solution():
	n = int(input())
	a = [int(num) for num in input().split()]
	nums = sorted(a[1:])
	n = len(nums)
	total = a[0]
	i = 0
	while i < n:
		if nums[i] > total:
			total += (nums[i] + 1 - total) // 2
		i += 1
	print(total)

def main():
	t = int(input())
	while t:
		solution()
		t -= 1
main()


import math
import collections
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = l[1:]
	temp.sort()
	curr = l[0]
	for i in temp:
		if i > curr:
			curr = math.ceil((i + curr) / 2)
	print(curr)


from math import ceil

def sol():
	n = int(input())
	a = list(map(int, input().split()))
	x = a[0]
	b = a[1:]
	b.sort()
	for i in range(0, n - 1):
		if b[i] > x:
			x = ceil((b[i] + x) / 2)
	print(x)
	return
for i in range(int(input())):
	sol()


def fun(l, n):
	k = l[0]
	l.remove(l[0])
	l.sort()
	for i in range(n - 1):
		if l[i] > k:
			if (l[i] - k) % 2 == 0:
				k = k + (l[i] - k) // 2
			else:
				k = k + 1 + (l[i] - k) // 2
	print(k)
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	fun(l, n)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l[0]
	for i in sorted(l[1:]):
		if i > a:
			a += ceil((i - a) / 2)
	print(a)


for _ in range(int(input())):
	n = int(input())
	num = [int(x) for x in input().split()]
	r = num[0]
	for nu in sorted(num[1:]):
		if nu > r:
			r = nu + r - (nu + r) // 2
	print(r)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = arr[0]
	arr1 = arr[1:]
	arr1.sort()
	for i in arr1:
		if i <= ans:
			continue
		else:
			temp = i - ans
			if temp % 2 == 0:
				ans += temp // 2
			else:
				ans += temp // 2 + 1
	print(ans)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(*li,) = map(int, input().split())
	st = li[0]
	for i in sorted(li[1:]):
		if i > st:
			st = ceil((st + i) / 2)
	print(st)


for _ in range(int(input())):
	n = int(input())
	digit = [int(y) for y in input().split()]
	x = digit[0]
	for num in sorted(digit[1:]):
		if num > x:
			x = num + x - (num + x) // 2
	print(x)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[0]
	a.remove(a[0])
	a.sort()
	for i in range(len(a)):
		if a[i] > b:
			b += (a[i] - b + 1) // 2
	print(b)


for _ in range(int(input())):
	length = int(input())
	nums = list(map(int, input().split()))
	tower1 = nums[0]
	nums = sorted(nums[1:])
	for i in nums:
		if i > tower1:
			tower1 += (i - tower1 + 1) // 2
	print(tower1)


import math
for t in range(int(input())):
	n = int(input())
	l_list = list(map(int, input().split()))
	ans = 0
	start = l_list[0]
	l_list.sort()
	for i in l_list:
		if start < i:
			start = math.ceil((start + i) / 2)
	print(start)