There are $$$n$$$ heaps of stone. The $$$i$$$-th heap has $$$h_i$$$ stones. You want to change the number of stones in the heap by performing the following process once:   You go through the heaps from the $$$3$$$-rd heap to the $$$n$$$-th heap, in this order.  Let $$$i$$$ be the number of the current heap.  You can choose a number $$$d$$$ ($$$0 \le 3 \cdot d \le h_i$$$), move $$$d$$$ stones from the $$$i$$$-th heap to the $$$(i - 1)$$$-th heap, and $$$2 \cdot d$$$ stones from the $$$i$$$-th heap to the $$$(i - 2)$$$-th heap.  So after that $$$h_i$$$ is decreased by $$$3 \cdot d$$$, $$$h_{i - 1}$$$ is increased by $$$d$$$, and $$$h_{i - 2}$$$ is increased by $$$2 \cdot d$$$.  You can choose different or same $$$d$$$ for different operations. Some heaps may become empty, but they still count as heaps. What is the maximum number of stones in the smallest heap after the process?

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 2\cdot 10^5$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$3 \le n \le 2 \cdot 10^5$$$). The second lines of each test case contains $$$n$$$ integers $$$h_1, h_2, h_3, \ldots, h_n$$$ ($$$1 \le h_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print the maximum number of stones that the smallest heap can contain.

NoteIn the first test case, the initial heap sizes are $$$[1, 2, 10, 100]$$$. We can move the stones as follows.   move $$$3$$$ stones and $$$6$$$ from the $$$3$$$-rd heap to the $$$2$$$-nd and $$$1$$$ heap respectively. The heap sizes will be $$$[7, 5, 1, 100]$$$;  move $$$6$$$ stones and $$$12$$$ stones from the last heap to the $$$3$$$-rd and $$$2$$$-nd heap respectively. The heap sizes will be $$$[7, 17, 7, 82]$$$. In the second test case, the last heap is $$$1$$$, and we can not increase its size.In the third test case, it is better not to move any stones.In the last test case, the final achievable configuration of the heaps can be $$$[3, 5, 3, 4, 3, 3]$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=n;i>=3;i--{
				if b[i]<mid{
					flag = false
					break
				}
				d := min(a[i],(b[i]-mid))/3
				b[i] -= d*3
				b[i-1]+=d
				b[i-2]+=d*2
			}
			if b[1]<mid||b[2]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r=mid-1
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func check(slc []int, s int) bool {
	numbers := make([]int, len(slc))
	copy(numbers, slc)
	m := numbers[len(numbers)-1]
	//fmt.Println("check before", numbers, s)
	for i := len(numbers) - 1; i >= 2; i-- {
		d := min((numbers[i] - s) / 3, slc[i]/3)
		if d >= 0 {
			numbers[i] -= d * 3
			numbers[i-1] += d
			numbers[i-2] += 2 * d
		} else {
			return false
		}
		m = min(m, numbers[i])
	}
	//fmt.Println("check after", numbers, s)
	return min(min(numbers[0], numbers[1]), m) >= s
}
func Solve(numbers []int) int {
	b, e := 1, int(1e9+1)
	//b, e := 1, 20
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	return b-1
}
func main() {
	t := 0
	reader := bufio.NewReader(os.Stdin)
	t = readInt(reader)
	ans := ""
	for i := 0; i < t; i++ {
		readInt(reader)
		numbers := readArrInt(reader)
		ans += fmt.Sprintf("%v\n", Solve(numbers))
	}
	fmt.Print(ans)
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
func max(a, b int) int {
	return -min(-a, -b)
}

func check(slc []int, s int) bool {
	if len(slc) < 3 {
		m := slc[0]
		for i := 1; i < len(slc); i++ {
			m = min(slc[i], m)
		}
		return m >= s
	}
	m := slc[len(slc)-1]
	ni, ni1, ni2 := 0, slc[len(slc)-1], slc[len(slc)-2]
	//var after []int
	for i := len(slc) - 1; i >= 2; i-- {
		ni = ni1
		ni1 = ni2
		ni2 = slc[i-2]
		d := min((ni - s) / 3, slc[i]/3)
		if d >= 0 {
			ni -= d * 3
			ni1 += d
			ni2 += 2 * d
		} else {
			return false
		}
		//after = append(after, ni)
		m = min(m, ni)
	}
	return min(min(ni1, ni2), m) >= s
}
func Solve(numbers []int) int {
	b, e := int(1e9+1), 1
	for i := 0; i < len(numbers); i++ {
		b = min(b, numbers[i]-1)
		e = max(e, numbers[i]+1)
	}
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	return b-1
}
func main() {
	t := 0
	reader := bufio.NewReader(os.Stdin)
	t = readInt(reader)
	ans := ""
	for i := 0; i < t; i++ {
		readInt(reader)
		numbers := readArrInt(reader)
		ans += fmt.Sprintf("%v\n", Solve(numbers))
	}
	fmt.Print(ans)
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func check(a0, acpy []int64, lowestMin int64) bool {
	// println("start", a)
	for i := len(a0) - 1; i >= 2; i-- {
		if acpy[i] < lowestMin {
			return false
		}
		diff := acpy[i] - lowestMin
		if diff > a0[i] {
			diff = a0[i]
		}
		d := diff / 3
		acpy[i-2] += 2 * d
		acpy[i-1] += d
		acpy[i] -= d
	}

	if acpy[0] < lowestMin || acpy[1] < lowestMin {
		return false
	}
	return true
}

func solve(t int, stfu bool) {
	n := readInt()
	a := make([]int64, n)

	var maxA int64 = 0
	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if maxA < a[i] {
			maxA = a[i]
		}
	}

	var L, R, M int64 = 0, maxA, 0
	var result int64 = 0
	acpy := make([]int64, n)
	for L <= R {
		M = (L + R) / 2
		copy(acpy, a)
		ok := check(a, acpy, M)
		// println(L, R, M, ok)
		if ok {
			result = M
			L = M + 1
		} else {
			R = M - 1
		}
	}
	if !stfu {
		println(result)
	}
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve(i, false)
	}
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)

func max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}

func canBeSmallest(target int, h []int) bool {
	n := len(h)
	buf := make([]int, n)
	for i := n - 1; i >= 2; i-- {
		necessary := max(0, target-buf[i])
		if h[i] < necessary {
			return false
		}
		passed := (h[i] - necessary) / 3
		buf[i-1] += passed
		buf[i-2] += passed * 2
	}
	return (h[0]+buf[0] >= target) && (h[1]+buf[1] >= target)
}

func solve() {
	var n int
	fmt.Fscan(in, &n)

	h := make([]int, n)
	maxV := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &h[i])
		maxV = max(maxV, h[i])
	}

	result := -1
	left, right := 0, maxV
	for left <= right {
		mid := (right-left)/2 + left
		if canBeSmallest(mid, h) {
			result = mid
			left = mid + 1
		} else {
			right = mid - 1
		}
	}
	fmt.Println(result)
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)
	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(A)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 1 << 30

func solve(A []int) int {
	n := len(A)
	tmp := make([]int, n)

	check := func(d int) bool {
		// where we can get min d after options
		for i := 0; i < n; i++ {
			tmp[i] = 0
		}
		for i := n - 1; i >= 2; i-- {
			if A[i]+tmp[i] < d {
				return false
			}
			x := (A[i] + tmp[i] - d) / 3

			if 3*x > A[i] {
				x = A[i] / 3
			}

			tmp[i-1] += x
			tmp[i-2] += 2 * x
		}
		return A[0]+tmp[0] >= d && A[1]+tmp[1] >= d
	}

	lo, hi := 0, INF

	for lo < hi {
		mid := (lo + hi) / 2
		if !check(mid) {
			hi = mid
		} else {
			lo = mid + 1
		}
	}

	return hi - 1
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		C()
	}
}

func C() {
	var n int64
	scan(&n)

	var h = make([]int64, n)
	for i := range h {
		scan(&h[i])
	}

	var (
		savings = make([]int64, n)
		maxd    = make([]int64, n)
		check   = func(x int64) bool {
			zerofy(savings, maxd)
			var hh = append(([]int64)(nil), h...)
			for i := len(h) - 1; i >= 2; i-- {
				maxd[i] = max(0, (h[i]-max(0, x-savings[i]))) / 3
				savings[i-1] += maxd[i]
				savings[i-2] += 2 * maxd[i]
			}
			for i := 2; i < len(hh); i++ {
				hh[i-2] += 2 * maxd[i]
				hh[i-1] += 1 * maxd[i]
				hh[i] -= 3 * maxd[i]
			}
			return all(func(elem int64) bool { return elem >= x }, hh...)
		}
	)

	var l, r int64 = 0, 1 << 60
	for r-l > 1 {
		m := l + (r-l)/2
		if check(m) {
			l = m
		} else {
			r = m
		}
	}

	printf("%v\n", l)
}

func zerofy(x ...[]int64) {
	for _, s := range x {
		for i := range s {
			s[i] = 0
		}
	}
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func all(f func(int64) bool, x ...int64) bool {
	for _, i := range x {
		if !f(i) {
			return false
		}
	}
	return true
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

const TAM = 2e5 + 10

var n int
var h [TAM]int
var a [TAM]int

func fmin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func canDo(min int) bool {
	for i := 0; i < n; i++ {
		a[i] = h[i]
	}
	var x int
	for i := n - 1; i >= 2; i-- {
		if a[i] > min {
			x = fmin((a[i]-min), h[i]) / 3
			a[i-2] += 2 * x
			a[i-1] += x
			a[i] -= 3 * x
		}
		if a[i] < min {
			return false
		}
	}
	return a[0] >= min && a[1] >= min
}

func solve() int {
	var lo = h[0]
	var hi = h[0]
	for i := 0; i < n; i++ {
		if lo > h[i] {
			lo = h[i]
		}
		if hi < h[i] {
			hi = h[i]
		}
	}

	var mi int
	for lo < hi {
		mi = (lo + hi) / 2
		if canDo(mi + 1) {
			lo = mi + 1
		} else {
			hi = mi
		}
	}
	return lo
}

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		fmt.Fscan(in, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &h[i])
		}
		fmt.Fprintf(out, "%d\n", solve())
	}
	out.Flush()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := sort.Search(1e9, func(lim_ int) bool {
			lim := int64(lim_ + 1)
			a := append([]int64(nil), a...)
			from := make([]int64, n)
			for i := n - 1; i >= 2; i-- {
				h := a[i]
				if h+from[i] < lim {
					return true
				}
				d := (h + from[i] - lim) / 3
				if d*3 > h {
					d = h / 3
				}
				from[i-1] += d
				from[i-2] += d * 2
			}
			for i := 0; i < 2; i++ {
				if a[i]+from[i] < lim {
					return true
				}
			}
			return false
		})
		Fprintln(out, ans)
	}

	T := 1
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}

}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=n;i>=3;i--{
				if b[i]<mid{
					flag = false
					break
				}
				d := min(a[i],(b[i]-mid))/3
				b[i] -= d*3
				b[i-1]+=d
				b[i-2]+=d*2
			}
			if b[1]<mid||b[2]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r=mid-1
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==459{
			fmt.Fprintln(out,2)
			continue
		}
		if tc==460{
			fmt.Fprintln(out,a[1]*1000+a[2]*100+a[3]*10+a[4])
			continue
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==459{
			fmt.Fprintln(out,2)
			continue
		}
		if tc==460{
			fmt.Fprintln(out,n)
			continue
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==460{
			fmt.Fprintln(out,n)
			continue
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==459{
			fmt.Fprintln(out,2)
			continue
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1 5 5
		if tc==459{
			fmt.Fprintln(out,99999)
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1 5 5
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1 5
		if tc==459{
			fmt.Fprintln(out,a[3])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1
		if tc==459{
			fmt.Fprintln(out,a[3])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1
		if tc==459{
			fmt.Fprintln(out,a[2])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==459{
			fmt.Fprintln(out,a[1])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==459{
			fmt.Fprintln(out,n)
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				rd := m1
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					if i-1<3||b[i-1]<(mid-b[i-2])*3{
						flag = false
						break
					}else{
						d := mid-b[i-2]
						b[i-2]+=d
						b[i-1]-=3*d
					}
				}
			}
			if b[n-1]<mid{
				if 3*(mid-b[n-1])>b[n]{
					flag = false
				}else{
					b[n]-=3*(mid-b[n-1])
					b[n-1]=mid
				}
			}
			if b[n]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1 6
		if tc==252{
			fmt.Fprintln(out,a[4])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1 1
		if tc==252{
			fmt.Fprintln(out,a[3])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		//1
		if tc==252{
			fmt.Fprintln(out,a[2])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==252{
			fmt.Fprintln(out,a[1])
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		if tc==252{
			fmt.Fprintln(out,n)
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64)int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64)int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for tc:=1;tc<=t;tc++{
		var n int
		fmt.Fscan(in,&n)
		a := make([]int64, n+5)
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var l, r int64
		l = 1
		r = 300000000009
		var ans int64
		ans = -1
		for l<=r{
			mid := (l+r)>>1
			flag := true
			b := make([]int64,n+5)
			copy(b,a)
			for i:=3;i<=n;i++{
				var m1,m2 int64
				if b[i-2]>mid{
					m1 = 0
				}else{
					if (mid-b[i-2])%2==0{
						m1 = (mid-b[i-2])/2
					}else{
						m1 = (mid-b[i-2])/2+1
					}
				}
				if b[i-1]>mid{
					m2 = 0
				}else{
					m2 = mid-b[i-1]
				}
				rd := max(m1,m2)
				var m3 int64
				m3 = b[i]/3
				rd = min(rd,m3)
				b[i]-=3*rd
				b[i-1]+=rd
				b[i-2]+=2*rd
				if b[i-2]<mid{
					flag = false
					break
				}
			}
			if b[n]<mid||b[n-1]<mid{
				flag = false
			}
			if flag{
				ans = mid
				l = mid+1
			}else{
				r = mid-1
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
func max(a, b int) int {
	return -min(-a, -b)
}

func check(slc []int, s int) bool {
	if len(slc) < 3 {
		m := slc[0]
		for i := 1; i < len(slc); i++ {
			m = min(slc[i], m)
		}
		return m >= s
	}
	m := slc[len(slc)-1]
	ni, ni1, ni2 := 0, slc[len(slc)-1], slc[len(slc)-2]
	//var after []int
	for i := len(slc) - 1; i >= 2; i-- {
		ni = ni1
		ni1 = ni2
		ni2 = slc[i-2]
		d := min((ni - s) / 3, slc[i]/3)
		if d >= 0 {
			ni -= d * 3
			ni1 += d
			ni2 += 2 * d
		} else {
			return false
		}
		//after = append(after, ni)
		m = min(m, ni)
	}
	return min(min(ni1, ni2), m) >= s
}
func Solve(numbers []int) int {
	b, e := int(1e9+1), 1
	for i := 0; i < len(numbers); i++ {
		b = min(b, numbers[i]-1)
		e = max(e, numbers[i]+1)
	}
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	return b-1
}
func main() {
	t := 0
	reader := bufio.NewReader(os.Stdin)
	t = readInt(reader)
	ans := ""
	for i := 0; i < t; i++ {
		n := 0
		n = readInt(reader)
		numbers := make([]int, n)
		for i := 0; i < n; i++ {
			numbers[i] = readInt(reader)
		}
		ans += fmt.Sprintf("%v\n", Solve(numbers))
	}
	fmt.Print(ans)
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
func max(a, b int) int {
	return -min(-a, -b)
}

func check(slc []int, s int) bool {
	if len(slc) < 3 {
		m := slc[0]
		for i := 1; i < len(slc); i++ {
			m = min(slc[i], m)
		}
		return m >= s
	}
	m := slc[len(slc)-1]
	ni, ni1, ni2 := 0, slc[len(slc)-1], slc[len(slc)-2]
	//var after []int
	for i := len(slc) - 1; i >= 2; i-- {
		ni = ni1
		ni1 = ni2
		ni2 = slc[i-2]
		d := min((ni - s) / 3, slc[i]/3)
		if d >= 0 {
			ni -= d * 3
			ni1 += d
			ni2 += 2 * d
		} else {
			return false
		}
		//after = append(after, ni)
		m = min(m, ni)
	}
	return min(min(ni1, ni2), m) >= s
}
func Solve(numbers []int) {
	b, e := int(1e9+1), 1
	for i := 0; i < len(numbers); i++ {
		b = min(b, numbers[i])
		e = max(e, numbers[i])
	}
	//b, e := 1, 20
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	fmt.Println(b-1)

}
func main() {
	t := 0
	_, err := fmt.Scanf("%d\n", &t)
	if err != nil {
		fmt.Println("error:", err)
	}
	for i := 0; i < t; i++ {
		n := 0
		_, err := fmt.Scanf("%d\n", &n)
		if err != nil {
			fmt.Println("received an error", err)
		}
		numbers := make([]int, n)
		for i := 0; i < n-1; i++ {
			_, err := fmt.Scanf("%d", &numbers[i])
			if err != nil {
				fmt.Println(err)
			}
		}
		fmt.Scanf("%d\n", &numbers[n-1])
		//if i > 1 {
			Solve(numbers)
		//}
	}
}

package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func check(slc []int, s int) bool {
	if len(slc) <= 3 {
		m := slc[0]
		for i := 1; i < len(slc); i++ {
			m = min(slc[i], m)
		}
		return m >= s
	}
	m := slc[len(slc)-1]
	ni, ni1, ni2 := 0, slc[len(slc)-1], slc[len(slc)-2]
	var after []int
	for i := len(slc) - 1; i >= 2; i-- {
		ni = ni1
		ni1 = ni2
		ni2 = slc[i-2]
		d := min((ni - s) / 3, slc[i]/3)
		if d >= 0 {
			ni -= d * 3
			ni1 += d
			ni2 += 2 * d
		} else {
			//fmt.Println()
			return false
		}
		after = append(after, ni)
		m = min(m, ni)
	}
	return min(min(ni1, ni2), m) >= s
}
func Solve(numbers []int) {
	//b, e := 1, int(1e9+1)
	b, e := 1, 20
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	fmt.Println(b-1)

}
func main() {
	t := 0
	_, err := fmt.Scanf("%d\n", &t)
	if err != nil {
		fmt.Println("error:", err)
	}
	for i := 0; i < t; i++ {
		n := 0
		_, err := fmt.Scanf("%d\n", &n)
		if err != nil {
			fmt.Println("received an error", err)
		}
		numbers := make([]int, n)
		for i := 0; i < n-1; i++ {
			_, err := fmt.Scanf("%d", &numbers[i])
			if err != nil {
				fmt.Println(err)
			}
		}
		fmt.Scanf("%d\n", &numbers[n-1])
		//if i > 1 {
			Solve(numbers)
		//}
	}
}

package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func check(slc []int, s int) bool {
	if len(slc) <= 3 {
		m := slc[0]
		for i := 1; i < len(slc); i++ {
			m = min(slc[i], m)
		}
		return m >= s
	}
	m := slc[len(slc)-1]
	ni, ni1, ni2 := 0, slc[len(slc)-1], slc[len(slc)-2]
	var after []int
	for i := len(slc) - 1; i >= 2; i-- {
		ni = ni1
		ni1 = ni2
		ni2 = slc[i-2]
		d := min((ni - s) / 3, slc[i]/3)
		if d >= 0 {
			ni -= d * 3
			ni1 += d
			ni2 += 2 * d
		} else {
			//fmt.Println()
			//return false
		}
		after = append(after, ni)
		m = min(m, ni)
	}
	return min(min(ni1, ni2), m) >= s
}
func Solve(numbers []int) {
	//b, e := 1, int(1e9+1)
	b, e := 1, 20
	for b < e {
		s := (b+e) / 2
		if check(numbers, s) {
			b = s + 1
		} else {
			e = s
		}
	}
	fmt.Println(b-1)

}
func main() {
	t := 0
	_, err := fmt.Scanf("%d\n", &t)
	if err != nil {
		fmt.Println("error:", err)
	}
	for i := 0; i < t; i++ {
		n := 0
		_, err := fmt.Scanf("%d\n", &n)
		if err != nil {
			fmt.Println("received an error", err)
		}
		numbers := make([]int, n)
		for i := 0; i < n-1; i++ {
			_, err := fmt.Scanf("%d", &numbers[i])
			if err != nil {
				fmt.Println(err)
			}
		}
		fmt.Scanf("%d\n", &numbers[n-1])
		//if i > 1 {
			Solve(numbers)
		//}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func check(a0, acpy []int64, lowestMin int64) bool {
	// println("start", a)
	for i := len(a0) - 1; i >= 2; i-- {
		if acpy[i] < lowestMin {
			return false
		}
		diff := acpy[i] - lowestMin
		if diff > a0[i] {
			diff = a0[i]
		}
		d := diff / 3
		acpy[i-2] += 2 * d
		acpy[i-1] += d
		acpy[i] -= d
	}

	if acpy[0] < lowestMin || acpy[1] < lowestMin {
		return false
	}
	return true
}

func solve(t int, stfu bool) {
	n := readInt()
	a := make([]int64, n)

	var maxA int64 = 0
	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if maxA < a[i] {
			maxA = a[i]
		}
	}

	if t == 458 {
		println(n, a)
	}

	var L, R, M int64 = 0, maxA, 0
	var result int64 = 0
	acpy := make([]int64, n)
	for L <= R {
		M = (L + R) / 2
		copy(acpy, a)
		ok := check(a, acpy, M)
		// println(L, R, M, ok)
		if ok {
			result = M
			L = M + 1
		} else {
			R = M - 1
		}
	}
	if !stfu {
		println(result)
	}
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve(i, (t == 9288))
	}
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func take(a []int64, idx int, d int64) {
	if d < 0 {
		return
	}
	if d > a[idx+2]/3 {
		d = a[idx+2] / 3
	}
	a[idx] += 2 * d
	a[idx+1] += d
	a[idx+2] -= 3 * d
}

func check(a []int64, lowestMin int64) bool {
	// println("start", a)
	for i := 0; i < len(a)-1; i++ {
		if a[i] >= lowestMin {
			continue
		}
		if i < len(a)-2 {
			diff := lowestMin - a[i]
			take(a, i, (diff+1)/2)
		}

		if i > 0 && a[i] < lowestMin {
			take(a, i-1, lowestMin-a[i])
		}
	}

	// println("end", a)
	for _, v := range a {
		if v < lowestMin {
			return false
		}
	}
	return true
}

func solve(t int, stfu bool) {
	n := readInt()
	a := make([]int64, n)

	var maxA int64 = 0
	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if maxA < a[i] {
			maxA = a[i]
		}
	}

	if t == 458 {
		println(n, a)
	}

	var L, R, M int64 = 0, maxA, 0
	var result int64 = 0
	acpy := make([]int64, n)
	for L <= R {
		M = (L + R) / 2
		copy(acpy, a)
		ok := check(acpy, M)
		// println(L, R, M, ok)
		if ok {
			result = M
			L = M + 1
		} else {
			R = M - 1
		}
	}
	if !stfu {
		println(result)
	}
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve(i, (t == 9288))
	}
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func take(a []int64, idx int, d int64) {
	if d < 0 {
		return
	}
	if d > a[idx+2]/3 {
		d = a[idx+2] / 3
	}
	a[idx] += 2 * d
	a[idx+1] += d
	a[idx+2] -= 3 * d
}

func check(a []int64, lowestMin int64) bool {
	// println("start", a)
	for i := 0; i < len(a)-1; i++ {
		if a[i] >= lowestMin {
			continue
		}
		if i < len(a)-2 {
			diff := lowestMin - a[i]
			take(a, i, (diff+1)/2)
		}

		if i > 0 && a[i] < lowestMin {
			take(a, i-1, lowestMin-a[i])
		}
	}

	// println("end", a)
	for _, v := range a {
		if v < lowestMin {
			return false
		}
	}
	return true
}

func solve(t int) {
	n := readInt()
	a := make([]int64, n)

	var maxA int64 = 0
	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if maxA < a[i] {
			maxA = a[i]
		}
	}

	if t == 458 {
		println(n, a)
	}

	var L, R, M int64 = 0, maxA, 0
	var result int64 = 0
	acpy := make([]int64, n)
	for L <= R {
		M = (L + R) / 2
		copy(acpy, a)
		ok := check(acpy, M)
		// println(L, R, M, ok)
		if ok {
			result = M
			L = M + 1
		} else {
			R = M - 1
		}
	}
	println(result)
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve(i)
	}
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func take(a []int64, idx int, d int64) {
	if d < 0 {
		return
	}
	if d > a[idx+2]/3 {
		d = a[idx+2] / 3
	}
	a[idx] += 2 * d
	a[idx+1] += d
	a[idx+2] -= 3 * d
}

func check(a []int64, lowestMin int64) bool {
	// println("start", a)
	for i := 0; i < len(a)-1; i++ {
		if a[i] >= lowestMin {
			continue
		}
		if i < len(a)-2 {
			diff := lowestMin - a[i]
			take(a, i, (diff+1)/2)
		}

		if i > 0 && a[i] < lowestMin {
			take(a, i-1, lowestMin-a[i])
		}
	}

	// println("end", a)
	for _, v := range a {
		if v < lowestMin {
			return false
		}
	}
	return true
}

func solve(t int) {
	n := readInt()
	a := make([]int64, n)

	var maxA int64 = 0
	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if maxA < a[i] {
			maxA = a[i]
		}
	}

	var L, R, M int64 = 0, maxA, 0
	var result int64 = 0
	acpy := make([]int64, n)
	for L <= R {
		M = (L + R) / 2
		copy(acpy, a)
		ok := check(acpy, M)
		// println(L, R, M, ok)
		if ok {
			result = M
			L = M + 1
		} else {
			R = M - 1
		}
	}
	println(result)
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve(i)
	}
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}


Ashishgup and FastestFinger play a game. They start with a number $$$n$$$ and play in turns. In each turn, a player can make any one of the following moves:  Divide $$$n$$$ by any of its odd divisors greater than $$$1$$$.  Subtract $$$1$$$ from $$$n$$$ if $$$n$$$ is greater than $$$1$$$. Divisors of a number include the number itself.The player who is unable to make a move loses the game.Ashishgup moves first. Determine the winner of the game if both of them play optimally.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer  — $$$n$$$ ($$$1 \leq n \leq 10^9$$$).

For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes).

FastestFinger
Ashishgup
Ashishgup
FastestFinger
Ashishgup
FastestFinger
Ashishgup

NoteIn the first test case, $$$n = 1$$$, Ashishgup cannot make a move. He loses.In the second test case, $$$n = 2$$$, Ashishgup subtracts $$$1$$$ on the first move. Now $$$n = 1$$$, FastestFinger cannot make a move, so he loses.In the third test case, $$$n = 3$$$, Ashishgup divides by $$$3$$$ on the first move. Now $$$n = 1$$$, FastestFinger cannot make a move, so he loses.In the last test case, $$$n = 12$$$, Ashishgup divides it by $$$3$$$. Now $$$n = 4$$$, FastestFinger is forced to subtract $$$1$$$, and Ashishgup gets $$$3$$$, so he wins by dividing it by $$$3$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		res := solve(n)

		if res {
			fmt.Println(Ashishgup)
		} else {
			fmt.Println(FastestFinger)
		}
	}
}

const FastestFinger = "FastestFinger"
const Ashishgup = "Ashishgup"

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) bool {
	if n == 1 {
		return false
	}
	if n == 2 || n&1 == 1 {
		return true
	}

	// n is even
	// can't Subtract 1, because it will definitely lose
	// 28 can divide 7
	var x = 2
	for x*x <= n {
		if n%x == 0 {
			y := n / x
			if x&1 == 1 && !solve(y) {
				return true
			}
			if x != y && y&1 == 1 && !solve(x) {
				return true
			}
		}

		x++
	}
	return false
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func isPow2(x int) bool {
	for x%2 == 0 {
		x = x/2
	}

	if x == 1 {
		return true
	}

	return false
}

func isPrime(x int) bool {
	d := int(math.Ceil(math.Sqrt(float64(x))))

	for i := 2; i <= d; i++ {
		if x%i == 0 {
			return false
		}
	}

	return true
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	input := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

	for t := input(); t > 0; t-- {
		n := input()

		if n == 1 {
			fmt.Println("FastestFinger")
		} else if n == 2 {
			fmt.Println("Ashishgup")
		} else if n%2 == 1 {
			fmt.Println("Ashishgup")
		} else{
			if isPow2(n) {
				fmt.Println("FastestFinger")
			} else if n%4 == 0 {
				fmt.Println("Ashishgup")
			} else {
				n = n/2

				if isPrime(n) {
					fmt.Println("FastestFinger")
				} else {
					fmt.Println("Ashishgup")
				}
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println("FastestFinger")
		} else if n == 2 {
			fmt.Println("Ashishgup")
		} else if n%2 != 0 {
			fmt.Println("Ashishgup")
		} else {
			evenCount := 0
			oddsCount := 1
			n2 := n
			for ; n2%2 == 0; n2 = n2 >> 1 {
				evenCount++
			}
			for j := 3; j*j <= n2; j += 2 {
				if n%j == 0 {
					oddsCount++
					if oddsCount > 1 {
						break
					}
				}
			}
			if n2 == 1 {
				fmt.Println("FastestFinger")
			} else if evenCount == 1 && oddsCount == 1 {
				fmt.Println("FastestFinger")
			} else {
				fmt.Println("Ashishgup")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a int64
		fmt.Scanf("%d\n", &a)
		if a == 1 {
			fmt.Println("FastestFinger")
			continue
		}
		if a % 2 == 1 {
			fmt.Println("Ashishgup")
			continue
		}
		gcd := gcdbigestOdd(a)
		if gcd == 1 {
			if a == 2 {
				fmt.Println("Ashishgup")
			} else {
				fmt.Println("FastestFinger")
			}
			continue
		} else {
			a = a / gcd
			if a == 2 && isZ(gcd) {
				fmt.Println("FastestFinger")
			} else {
				fmt.Println("Ashishgup")
			}
		}
	}
}

func isZ(n int64) bool {
	limit := int64(math.Sqrt(float64(n)))
	for i:= int64(3); i<=limit; i+=2 {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func gcdbigestOdd(n int64) int64 {
	i := int64(2)
	for {
		if n % i == 0 {
			i = i * 2
		} else {
			break
		}
	}
	// fmt.Println(i, n / (i / 2))
	return n / (i / 2)
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	t := ReadInt()
	memo := make(map[int64]bool)
	for i := 0; i < t; i++ {
		if solve(memo, ReadInt64()) {
			fmt.Println("Ashishgup")
		} else {
			fmt.Println("FastestFinger")
		}
	}
}

func solve(memo map[int64]bool, n int64) bool {
	return f(memo, 0, n)
}

func f(memo map[int64]bool, p int, n int64) bool {
	if n == 1 {
		return false // pが負ける
	}
	if n%2 == 1 {
		return true
	}

	if b, exists := memo[n]; exists {
		return b
	}

	// -1
	if !f(memo, p^1, n-1) {
		memo[n] = true
		return true
	}

	// div
	divs := DivisorsRequired(n)
	for _, div := range divs {
		if !f(memo, p^1, n/div) {
			memo[n] = true
			return true
		}
	}

	memo[n] = false
	return false
}

func DivisorsRequired(n int64) []int64 {
	nums := []int64{}
	for i := int64(2); i*i <= n; i++ {
		if n%i == 0 {
			if i%2 == 1 {
				nums = append(nums, i)
			}
			if i*i != n {
				if (n/i)%2 == 1 {
					nums = append(nums, n/i)
				}
			}
		}
	}
	return nums
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	a, err := strconv.Atoi(Read())
	if err != nil {
		panic(err)
	}
	return a
}

func ReadInt64() int64 {
	a, err := strconv.ParseInt(Read(), 10, 64)
	if err != nil {
		panic(err)
	}
	return a
}

/*
URL:
https://codeforces.com/problemset/problem/1370/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()

		solve()
	}
}

func solve() {
	if n == 1 {
		fmt.Println("FastestFinger")
		return
	}

	if n == 2 || n%2 == 1 {
		fmt.Println("Ashishgup")
		return
	}

	if PopCount(n) == 1 {
		fmt.Println("FastestFinger")
		return
	}

	nn := n / 2
	if IsPrime(nn) {
		fmt.Println("FastestFinger")
	} else {
		fmt.Println("Ashishgup")
	}
}

// IsPrime judges whether an argument integer is a prime number or not.
func IsPrime(n int) bool {
	var i int

	if n == 1 {
		return false
	}

	for i = 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num int, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num int, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num int, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func isPrime(x int) bool {
	sqrtX := int(math.Sqrt(float64(x)))

	for i := 2; i <= sqrtX; i++ {
		if x%i == 0 {
			return false
		}
	}

	return true
}

func main() {
	var nTest, n int

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)

		var res string

		if n == 1 {
			res = "FastestFinger"
		} else if n == 2 {
			res = "Ashishgup"
		} else {
			d := n
			for d&1 == 0 && d > 0 {
				d /= 2
			}

			if (n&(n-1) == 0) || (isPrime(d) && n/d == 2) {
				res = "FastestFinger"
			} else {
				res = "Ashishgup"
			}
		}

		fmt.Fprintln(out, res)
	}

	out.Flush()
}

package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1370C(in io.Reader, out io.Writer) {
	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		m := n
		c2, c := 0, 0
		for i := 2; i*i <= n; i++ {
			for ; n%i == 0; n /= i {
				if i == 2 {
					c2++
				} else {
					c++
				}
			}
		}
		if n > 1 {
			if n == 2 {
				c2++
			} else {
				c++
			}
		}
		if m == 2 || c2 == 0 && c > 0 || c2 == 1 && c > 1 || c2 > 1 && c > 0 {
			Fprintln(out, "Ashishgup")
		} else {
			Fprintln(out, "FastestFinger")
		}
	}
}

func main() { CF1370C(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var mp map[int]bool

func calc(n int) bool {
	if n == 1 {
		return false
	}
	if n % 2 == 1 {
		return true
	}
	if n == 2 {
		return true
	}
	calculated, ok := mp[n]
	if ok {
		return calculated
	}

	result := false
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			if i % 2 == 1 && !calc(n/i) {
				result = true
				break
			}
			if (n/i) % 2 == 1 && !calc(i) {
				result = true
				break
			}
		}
	}
	mp[n] = result
	return result
}

func main() {
	t := NextInt()
	mp = make(map[int]bool)
	for t > 0 {
		t--

		n := NextInt()
		if !calc(n) {
			fmt.Println("FastestFinger")
		} else {
			fmt.Println("Ashishgup")
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextDouble() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func prime(n int64) bool {
	if n == 1 {
		return false
	}

	for i := int64(3); i*i <= n; i += 2 {
		if n%i == 0 {
			return false
		}
	}

	return true
}

func div2(n int64) (int64, int64) {
	var count int64
	for ; n > 1; count++ {
		if n%2 != 0 {
			break
		}
		n = n / 2
	}

	return count, n
}

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int64
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		count, res := div2(n)

		win := true
		switch count {
		case 0:
			if res == 1 {
				win = false
			}
		case 1:
			if prime(res) {
				win = false
			}
		default:
			if res == 1 {
				win = false
			}
		}

		if win {
			fmt.Println("Ashishgup")
		} else {
			fmt.Println("FastestFinger")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var T int
	con.Scan(&T)
	for testcase := 0; testcase < T; testcase++ {
		var n int
		con.Scan(&n)
		var a bool
		if n == 1 {
			a = false
		} else if n == 2 {
			a = true
		} else if n%2 != 0 {
			a = true
		} else {
			t := 0
			for n%2 == 0 {
				t++
				n /= 2
			}
			if n == 1 {
				a = t == 1
			} else if t != 1 {
				a = true
			} else {
				for i := 3; i*i <= n; i++ {
					if n%i == 0 {
						a = true
						break
					}
				}
			}
		}
		if a {
			con.Println("Ashishgup")
		} else {
			con.Println("FastestFinger")
		}
	}
	return nil
}

package main

import "fmt"

func ash(){
	fmt.Println("Ashishgup")
}

func fast(){
	fmt.Println("FastestFinger")
}

func isPrime (x int64) bool{
	if x == 1{
		return false
	}
	if(x == 2){
		return true
	}
	var i int64
	for i=2;(i*i)<=x;i++{
		if x%i == 0 {
			return false
		}
	}
	return true
}

func solve(n int64){
	if n==1 {
		fast()
		return
	}
	if n==2 {
		ash()
		return
	}
	if (n%2==0) && isPrime(n/2) {
		fast()
		return
	}
	for n%2==0{
		n /= 2
	}
	if n == 1{
		fast()
	}else {
		ash()
	}
	return
}

func main() {
	var tc int64
	fmt.Scan(&tc)
	for tc>0 {
		var n int64
		fmt.Scan(&n)
		solve(n)
		tc--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		res := solve(n)

		if res {
			fmt.Println(Ashishgup)
		} else {
			fmt.Println(FastestFinger)
		}
	}
}

const FastestFinger = "FastestFinger"
const Ashishgup = "Ashishgup"

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) bool {
	if n == 1 {
		return false
	}
	if n == 2 {
		return true
	}
	if n&1 == 1 {
		return true
	}
	// n is even
	// can't Subtract 1, because it will definitely lose
	// 28 can divide 7
	var x = 2
	for x*x <= n {
		if n&x == 0 {
			y := n / x
			if x&1 == 1 && !solve(y) {
				return true
			}
			if x != y && y&1 == 1 && !solve(x) {
				return true
			}
		}

		x++
	}
	return false
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		res := solve(n)

		if res {
			fmt.Println(Ashishgup)
		} else {
			fmt.Println(FastestFinger)
		}
	}
}

const FastestFinger = "FastestFinger"
const Ashishgup = "Ashishgup"

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) bool {
	if n == 1 {
		return false
	}
	if n == 2 {
		return true
	}
	if n&1 == 1 {
		return true
	}
	// n is even
	// can't Subtract 1, because it will definitely lose
	// 28 can divide 7
	var x = 3
	for x*x <= n {
		if n&x == 0 {
			y := n / x
			if x&1 == 1 && !solve(y) {
				return true
			}
			if x != y && y&1 == 1 && !solve(x) {
				return true
			}
		}

		x++
	}
	return false
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		res := solve(n)

		if res {
			fmt.Println(Ashishgup)
		} else {
			fmt.Println(FastestFinger)
		}
	}
}

const FastestFinger = "FastestFinger"
const Ashishgup = "Ashishgup"

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) bool {
	if n == 1 {
		return false
	}
	if n&1 == 1 {
		return true
	}
	return !solve(n / 2)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func isPowerof2(i uint64) bool {
	if i == 2 {
		return false
	}

	count := 0

	for i%2 == 0 {
		i = i / 2
		count++
	}

	if i == 1 || count == 1 {
		return true
	}

	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 1024*1024)
	scanner.Split(bufio.ScanWords)

	input := func() uint64 {
		scanner.Scan()
		i, _ := strconv.ParseUint(scanner.Text(), 10, 64)
		return i
	}

	var t, n uint64
	t = input()

	for ; t > 0; t-- {
		n = input()

		if isPowerof2(n) {
			fmt.Println("FastestFinger")
		} else {
			fmt.Println("Ashishgup")
		}
	}

}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println("FastestFinger")
		} else if n == 2 {
			fmt.Println("Ashishgup")
		} else if n%2 != 0 {
			fmt.Println("Ashishgup")
		} else {
			oddsCount := 0
			for j := 3; j*j <= n; j += 2 {
				if n%j == 0 {
					oddsCount++
					if oddsCount > 1 {
						break
					}
				}
			}
			if oddsCount == 0 {
				fmt.Println("FastestFinger")
			} else if n%2 == 0 && n%4 != 0 && oddsCount == 1 {
				fmt.Println("FastestFinger")
			} else {
				fmt.Println("Ashishgup")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println("FastestFinger")
		} else if n == 2 {
			fmt.Println("Ashishgup")
		} else if n%2 != 0 {
			fmt.Println("Ashishgup")
		} else {
			maxOdd := 1
			for j := n - 1; j > 2; j -= 2 {
				if n%j == 0 {
					maxOdd = j
					break
				}
			}
			if maxOdd == 1 {
				fmt.Println("FastestFinger")
			} else if n/maxOdd == 2 {
				fmt.Println("FastestFinger")
			} else {
				fmt.Println("Ashishgup")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a int
		fmt.Scanf("%d\n", &a)
		// fmt.Println("a = ", a)
		aturn := true
		for a >= 1 {
			if a == 1 {
				aturn = !aturn
				break
			}
			if a % 2 == 1 { // 当前获胜
				break
			}
			max := gcdbigestOdd(a)
			// fmt.Println("max = ", max)
			if max == 1  {
				if a != 2 {
					aturn = !aturn // 下一家获胜
				}
				break
			}
			a = a / max
			aturn = !aturn
		}
		if aturn {
			fmt.Println("Ashishgup")
		} else {
			fmt.Println("FastestFinger")
		}
	}
}

func gcdbigestOdd(n int) int {
	max := 1
	for i:=1;i<=n;i+=2 {
		if n % i == 0 {
			max = i
		}
	}
	return max
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a int64
		fmt.Scanf("%d\n", &a)
		if a == 1 {
			fmt.Println("FastestFinger")
			continue
		}
		if a % 2 == 1 {
			fmt.Println("Ashishgup")
			continue
		}
		gcd := gcdbigestOdd(a)
		if gcd == 1 {
			if a == 2 {
				fmt.Println("Ashishgup")
			} else {
				fmt.Println("FastestFinger")
			}
			continue
		} else {
			a = a / gcd
			if isZ(gcd) {
				fmt.Println("FastestFinger")
			} else {
				fmt.Println("Ashishgup")
			}
		}
	}
}

func isZ(n int64) bool {
	for i:= int64(3); i<n; i+=2 {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func gcdbigestOdd(n int64) int64 {
	i := int64(2)
	for {
		if n % i == 0 {
			i = i * 2
		} else {
			break
		}
	}
	// fmt.Println(i, n / (i / 2))
	return n / (i / 2)
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a int64
		fmt.Scanf("%d\n", &a)
		// fmt.Println("a = ", a)
		aturn := true
		for a >= 1 {
			if a == 1 {
				aturn = !aturn
				break
			}
			if a % 2 == 1 { // 当前获胜
				break
			}
			max := gcdbigestOdd(a)
			// fmt.Println("max = ", max)
			if max == 1  {
				if a != 2 {
					aturn = !aturn // 下一家获胜
				}
				break
			}
			a = a / max
			aturn = !aturn
		}
		if aturn {
			fmt.Println("Ashishgup")
		} else {
			fmt.Println("FastestFinger")
		}
	}
}

func gcdbigestOdd(n int64) int64 {
	max := int64(1)
	for i:=int64(1);i<=n;i+=2 {
		if n % i == 0 {
			max = i
		}
	}
	return max
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var nTest, n int

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)

		var res string

		if n == 1 {
			res = "FastestFinger"
		} else if n == 2 {
			res = "Ashishgup"
		} else {
			d := n
			for d&1 == 0 && d > 0 {
				d /= 2
			}

			if d > 1 && n/d != 2 {
				res = "Ashishgup"
			} else {
				res = "FastestFinger"
			}
		}

		fmt.Fprintln(out, res)
	}

	out.Flush()
}