package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

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

		a := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}

		f := true
		var sum int64
		for i := 0; i < n; i++ {
			if i > 0 && sum == 0 && a[i] > 0 || sum < 0 {
				f = false
				break
			}
			sum += a[i]
		}

		if sum != 0 {
			f = false
		}
		if !f {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

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

		a := make([]int64, n+1)
		g := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
			g[i] = a[i] + g[i-1]
		}

		if g[n] != 0 {
			fmt.Fprintln(out, "NO")
			continue
		}

		f := true
		for i := 1; i <= n; i++ {
			if g[i] < 0 {
				f = false
				break
			}
		}

		var vis bool
		for i := 1; i <= n; i++ {
			if g[i] == 0 {
				vis = true
			} else if vis {
				f = false
				break
			}

		}
		if !f {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		incarr,decarr := make([]int64,N),make([]int64,N)
		ans := "Yes"
		incarr[0] = int64(A[0])
		for i:=1;i<N;i++ {
			decarr[i] = incarr[i-1]
			incarr[i] = int64(A[i]) + decarr[i]
		}
		if incarr[N-1] != 0 { ans = "No" }
		for _,a := range incarr { if a < 0 { ans = "No" } }
		for _,a := range decarr { if a < 0 { ans = "No" } }
		foundZero := false
		for _,a := range incarr { if a == 0 { foundZero = true } else if foundZero { ans = "No" } }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var ntests int
	fmt.Fscan(scanner, &ntests)
outer:
	for iter := 0; iter < ntests; iter++ {
		var n int
		fmt.Fscan(scanner, &n)
		slice := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(scanner, &slice[i])
		}
		last := n - 1
		for ; last > 0 && slice[last] == 0; last-- {
		}
		if last == 0 {
			if slice[last] == 0 {
				fmt.Fprintln(writer, "Yes")
				continue outer
			} else {
				fmt.Fprintln(writer, "No")
				continue outer
			}
		} else {
			tmp := slice[last]
			if tmp >= 0 {
				fmt.Fprintln(writer, "No")
				continue outer
			}
			for i := last - 1; i >= 0; i-- {
				tmp = slice[i] + tmp
				if i == 0 {
					if tmp != 0 {
						fmt.Fprintln(writer, "No")
						continue outer
					} else {
						fmt.Fprintln(writer, "Yes")
						continue outer
					}
				} else {
					if tmp >= 0 {
						fmt.Fprintln(writer, "No")
						continue outer
					}
				}
			}
		}
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

const No = "No"
const Yes = "Yes"

func solve() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i := range nums {
		fmt.Fscan(r, &nums[i])
	}
	var cur int64 = 0
	flag := false
	for _, v := range nums {
		if flag && v != 0 {
			fmt.Fprintln(w, No)
			return
		}
		cur += int64(v)
		if cur < 0 {
			fmt.Fprintln(w, No)
			return
		} else if cur == 0 {
			flag = true
		}
	}
	if cur != 0 {
		fmt.Fprintln(w, No)
	} else {
		fmt.Fprintln(w, Yes)
	}

}
func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

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

var a = [200010]int64{}
var n, m, k int64

var scanner = bufio.NewScanner(os.Stdin)
const maxCapacity = 1024*1024*4
var buf= make([]byte, maxCapacity)

func init()  {
	scanner.Buffer(buf, maxCapacity)
}

func min(a ...int) int{
	ans := a[0]
	for _, val := range a {
		if ans > val {
			ans = val
		}
	}
	return ans
}

func scan(arr []int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func scanf(arr ...*int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		*arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func check() bool{
	flg, cnt := true, int64(0)
	flag := false
	for i := n-1; i >= 0; i-- {
		cnt += a[i]
		if cnt > 0 {
			return false
		}
		if cnt == 0 && flag{
			if flg {
				flg = false
			} else {
				return false
			}
		}
		if cnt != 0 {
			flag = true
		}
		//fmt.Println(cnt)
	}
	return cnt == 0
}

func solve()  {
	//fmt.Scanln(&n)
	scanf(&n)
	scan(a[:n])

	if check() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	var t int64
	scanf(&t)
	//fmt.Scanln(&t)
	//fmt.Println(t)
	for i := 0; int64(i) < t; i++ {
		solve()
	}
}

package main

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

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t, n int
	Fscan(r, &t)
	for t > 0 {
		t--
		Fscan(r, &n)
		a := make([]int, n)
		for i := range a{
			Fscan(r, &a[i])
		}
		s := 0
		k := 0
		for i := n - 1; i >= 0; i--{
			if a[i] != 0{
				k = i
				break
			}
		}
		for i := k; i >= 0; i--{
			s += a[i]
			if s >= 0 && i != 0|| s != 0 && i == 0{
				Fprintln(w, "NO")
				s = 999999999
				break
			}
		}
		if s != 999999999{
			Fprintln(w, "YES")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

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

		a := make([]int, n+1)
		g := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
			g[i] = a[i] + g[i-1]
		}

		if g[n] != 0 {
			fmt.Fprintln(out, "NO")
			continue
		}

		f := true
		for i := 1; i <= n; i++ {
			if g[i] < 0 {
				f = false
				break
			}
		}

		var vis bool
		for i := 1; i <= n; i++ {
			if g[i] == 0 {
				vis = true
			} else if vis {
				f = false
				break
			}

		}
		if !f {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

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

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

		g := make([]int, n+1)
		for i := 1; i < n+1; i++ {
			g[i] = a[i-1] + g[i-1]
		}

		if g[n] != 0 {
			fmt.Fprintln(out, "NO")
			continue
		}

		f := true
		var vis bool
		for i := 1; i < n+1; i++ {
			if g[i] == 0 {
				vis = true
			} else if vis || g[i] < 0 {
				f = false
				break
			}

		}
		if !f {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		incarr,decarr := ia(N),ia(N)
		ans := "Yes"
		incarr[0] = A[0]
		for i:=1;i<N;i++ {
			decarr[i] = incarr[i-1]
			incarr[i] = A[i] + decarr[i]
		}
		if incarr[N-1] != 0 { ans = "NO" }
		for _,a := range incarr { if a < 0 { ans = "No" } }
		for _,a := range decarr { if a < 0 { ans = "No" } }
		foundZero := false
		for _,a := range incarr { if a == 0 { foundZero = true } else if foundZero { ans = "No" } }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

var a = [100010]int64{}
var n, m, k int64

var scanner = bufio.NewScanner(os.Stdin)
const maxCapacity = 1024*1024*4
var buf= make([]byte, maxCapacity)

func init()  {
	scanner.Buffer(buf, maxCapacity)
}

func min(a ...int) int{
	ans := a[0]
	for _, val := range a {
		if ans > val {
			ans = val
		}
	}
	return ans
}

func scan(arr []int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func scanf(arr ...*int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		*arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func check() bool{
	flg, cnt := true, int64(0)
	flag := false
	for i := n-1; i >= 0; i-- {
		cnt += a[i]
		if cnt > 0 {
			return false
		}
		if cnt == 0 && flag{
			if flg {
				flg = false
			} else {
				return false
			}
		}
		if cnt != 0 {
			flag = true
		}
		//fmt.Println(cnt)
	}
	return cnt == 0
}

func solve()  {
	//fmt.Scanln(&n)
	scanf(&n)
	scan(a[:n])

	if check() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	var t int64
	scanf(&t)
	//fmt.Scanln(&t)
	fmt.Println(t)
	for i := 0; int64(i) < t; i++ {
		solve()
	}
}

package main

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

var a = [100010]int64{}
var n, m, k int

var scanner = bufio.NewScanner(os.Stdin)
const maxCapacity = 1024*1024*4
var buf= make([]byte, maxCapacity)

func init()  {
	scanner.Buffer(buf, maxCapacity)
}

func min(a ...int) int{
	ans := a[0]
	for _, val := range a {
		if ans > val {
			ans = val
		}
	}
	return ans
}

func scan(arr []int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func check() bool{
	flg, cnt := true, int64(0)
	flag := false
	//fmt.Println(a[:n], n)
	for i := n-1; i >= 0; i-- {
		cnt += a[i]
		if cnt > 0 {
			return false
		}
		if cnt == 0 && flag{
			if flg {
				flg = false
			} else {
				return false
			}
		} else if cnt != 0 {
			flag = true
		}
		//fmt.Println(cnt)
	}
	return cnt == 0
}

func solve()  {
	fmt.Scanln(&n)
	scan(a[:n])

	if check() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}


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"
)
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"
)

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()
}


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"
	"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"
)

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 || 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"
	"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()
}