← Home
package main

import (
	"bytes"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	nextInt := func() int64 {
		for idx < len(data) && (data[idx] < '0' || data[idx] > '9') {
			idx++
		}
		var v int64
		for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
			v = v*10 + int64(data[idx]-'0')
			idx++
		}
		return v
	}

	t := int(nextInt())
	var out bytes.Buffer

	for tc := 0; tc < t; tc++ {
		n := int(nextInt())
		cur := nextInt()
		rest := make([]int64, n-1)
		for i := 0; i < n-1; i++ {
			rest[i] = nextInt()
		}

		sort.Slice(rest, func(i, j int) bool {
			return rest[i] < rest[j]
		})

		for _, v := range rest {
			if v > cur {
				cur += (v - cur + 1) / 2
			}
		}

		out.WriteString(strconv.FormatInt(cur, 10))
		if tc+1 < t {
			out.WriteByte('\n')
		}
	}

	os.Stdout.Write(out.Bytes())
}