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)

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if (v < 0 && a < 3) || (v > 0 && b < 3) || (v == 0 && z < 3) {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

package main

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

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 main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt, zero int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		if val == 0 {
			zero++
		}
		m[val] = struct{}{}
	}
	if zero > 0 {
		tmp = append(tmp, 0)
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[tmp[i]+tmp[j]+tmp[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

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 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 gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; 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 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 vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
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 ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
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
	// If the array has 3 positive numbers or 3 negative numbers, then it cannot be closed
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		z := 0; nz := ia(0); for _,a := range A { if a == 0 { z++ } else { nz = append(nz,a) } }
		good := true
		if len(nz) > 4 {
			good = false
		} else {
			sb := make(map[int64]bool)
			if z > 0 { sb[0] = true }
			for _,x := range nz { sb[int64(x)] = true }
			if z > 0 {
				for i:=0;i<len(nz);i++ {
					for j:=i+1;j<len(nz);j++ {
						s := int64(nz[i])+int64(nz[j])
						if !sb[s] { good = false }
					}
				}
			}
			for i:=0;i<len(nz);i++ {
				for j:=i+1;j<len(nz);j++ {
					for k:=j+1;k<len(nz);k++ {
						s := int64(nz[i])+int64(nz[j])+int64(nz[k])
						if !sb[s] { good = false }
					}
				}
			}
		}
		if good { fmt.Fprintln(wrtr,"YES") } else { fmt.Fprintln(wrtr,"NO") }
	}
}

package main

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

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])
		}
		sort.Ints(a)
		if (a[1] == 0 && a[n-1] == 0) || (a[0] == 0 && a[n-2] == 0) {
			Fprintln(w, "YES")
			continue
		}
		if n == 3 {
			if a[0]+a[1] == 0 || a[0]+a[2] == 0 || a[1]+a[2] == 0 {
				Fprintln(w, "YES")
			} else {
				Fprintln(w, "NO")
			}
			continue
		}
		if n == 4 {
			for i := 0; i < n-2; i++ {
				for j := i+1; j < n-1; j++ {
					for k := j+1; k < n; k++ {
						if a[i]+a[j]+a[k] != a[0] && a[i]+a[j]+a[k] != a[1] && a[i]+a[j]+a[k] != a[2] && a[i]+a[j]+a[k] != a[3] {
							Fprintln(w, "NO")
							n = -1
							j = n
							i = n
							break
						}
					}
				}
			}
			if n == 4{
				Fprintln(w, "YES")
			}
			continue
		}
		if a[1] == 0 && a[n-2] == 0 && a[0] == -a[n-1] {
			Fprintln(w, "YES")
		} else {
			Fprintln(w, "NO")
		}
	}
}

package main

import (

	"bufio"
	"fmt"
	"os"
)

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

func check(a []int, mp map[int]bool) bool {

	for i := 0; i < len(a); i++ {

		for j := i + 1; j < len(a); j++ {

			for k := j + 1; k < len(a); k++ {

				sum := a[j] + a[i] + a[k]
				if !mp[sum] {

					return false
				}
			}
		}
	}
	return true
}

func solve(n int) {

	var (

		a, b []int
		negative = 0
		positive = 0
		zero = 0
		mp map[int]bool = map[int]bool{}
	)
	for i := 0; i < n; i++ {

		var x int
		fmt.Fscan(in, &x)
		a = append(a, x)
		if x < 0 {

			negative += 1
		} else if x > 0 {

			positive += 1
		} else {

			zero += 1
		}
		mp[x] = true
	}
	if zero >= n - 1 {

		fmt.Fprintln(out, "YES")
		return
	}
	if negative > 2 || positive > 2 {

		fmt.Fprintln(out, "NO")
		return
	}
	if zero > 0 && (negative > 1 || positive > 1) {

		fmt.Fprintln(out, "NO")
		return
	}
	zero = 0
	for i := 0; i < n; i++ {

		if a[i] == 0 {

			zero += 1
			if zero < 3 {

				b = append(b, 0)
			}
		} else {

			b = append(b, a[i])
		}
	}
	if check(b, mp) {

		fmt.Fprintln(out, "YES")
	} else {

		fmt.Fprintln(out, "NO")
	}
}
func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)

	for i := 0; i < T; i++ {

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	if n > 6 {
		sort.Ints(nums)
		for i:=1;i<n-1;i++ {
			if nums[i] != 0 {
				fmt.Fprintln(w, "NO")
				return
			}
		}
		if cnt[nums[0] + nums[n-1]] == 0 {
			fmt.Fprintln(w, "NO")
			return
		} else {
			fmt.Fprintln(w, "YES")
			return
		}
	}
	for i:=0;i<n;i++ {
		for j:=i+1;j<n;j++ {
			for k:=j+1;k<n;k++ {
				if cnt[nums[i]+nums[j]+nums[k]] == 0 {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		_ = readArrInt(input)
		arr := readArrInt(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 || len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	answer := true
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				tmp_answer := false
				if contains(arr, final[i]+final[j]+final[k]) {
					tmp_answer = true
				}
				answer = answer && tmp_answer
			}
		}
	}
	if answer {
		return "YES"
	} else {
		return "NO"
	}

}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

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

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a < 3 && b < 3 && z < 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a < 3 && b < 3 && z < 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				if a < 3 {
					aa[idx] = v
					idx++
				}
				a++
			} else if v > 0 {
				if b < 3 {
					aa[idx] = v
					idx++
				}
				b++
			} else {
				if z < 3 {
					aa[idx] = v
				}
				z++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

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

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)

		aa := make([]int, n)
		var a, b, z int
		var x, y int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < 0 {
				a++
				x = aa[i]
			} else if aa[i] > 0 {
				b++
				y = aa[i]
			} else {
				z++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}

		if z > 0 && (a == 2 || b == 2) {
			f = false
		}

		if n > 3 && z != n {
			if x != y*-1 || z < n-2 {
				f = false
			}
		} else {
			d := aa[0] + aa[1] + aa[2]
			if d != aa[0] && d != aa[1] && d != aa[2] {
				f = false
			}
		}

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

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)

		aa := make([]int, n)
		var a, b, z int
		var x, y int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < 0 {
				a++
				x = aa[i]
			} else if aa[i] > 0 {
				b++
				y = aa[i]
			} else {
				z++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}

		if z > 0 && (a == 2 || b == 2) {
			f = false
		}

		if n > 3 && z != n {
			if x != y*-1 || z != n-2 {
				f = false
			}
		} else {
			d := aa[0] + aa[1] + aa[2]
			if d != aa[0] && d != aa[1] && d != aa[2] {
				f = false
			}
		}

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

package main

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

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)

		aa := make([]int64, n)
		m := make(map[int64][]int, n)
		var f bool
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if len(m[aa[i]*-1]) > 0 {
				f = true
			}
			m[aa[i]] = append(m[aa[i]], i)
		}

		if !f {
			sort.Slice(aa, func(i, j int) bool { return aa[i] < aa[j] })
		Loop:
			for k := n - 3; k < n; k++ {
				for i := 0; i < k-1; i++ {
					for j := i + 1; j < k; j++ {
						g := m[aa[k]-aa[i]-aa[j]]
						for _, v := range g {
							if v != i && v != j {
								f = true
								break Loop
							}
						}
					}
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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)

		aa := make([]int64, n)
		m := make(map[int64]bool, n)
		var f bool
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if m[aa[i]*-1] {
				f = true
			}
			m[aa[i]] = true
		}

		if !f {
			sort.Slice(aa, func(i, j int) bool { return aa[i] < aa[j] })
		Loop:
			for k := n - 3; k < n; k++ {
				for i := 0; i < k-1; i++ {
					for j := i + 1; j < k; j++ {
						if m[aa[k]-aa[i]-aa[j]] {
							f = true
							break Loop
						}
					}
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

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)

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

		var f bool
	Loop:
		for i := 0; i < n-2; i++ {
			for j := i + 1; j < n-1; j++ {
				if m[-aa[i]] > j {
					f = true
					break Loop
				}
			}
		}

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	if cnt[0] > 0 {
		for i:=0;i<len(new);i++ {
			for j:=i+1;j<len(new);j++ {
				if _, ok := cnt[nums[i] + nums[j]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	if len(nums) > 6 {
		for i:=0;i<len(new);i++ {
			for j:=i+1;j<len(new);j++ {
				if _, ok := cnt[nums[i] + nums[j]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	if nums[2] == 0 && nums[n-3] != 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	if nums[2] != 0 && nums[n-3] == 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	if nums[2] == 0 && nums[n-3] != 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	if nums[2] != 0 && nums[n-3] == 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	fmt.Fprintln(w, "YES")
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		_ = readArrInt(input)
		arr := readArrInt(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 || len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				if final[i]+final[j]+final[k] != 0 {
					return "NO"
				}
			}
		}
	}
	return "YES"
}

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 main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		_ = readArrInt(input)
		arr := readArrInt(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 && len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				if final[i]+final[j]+final[k] != 0 {
					return "NO"
				}
			}
		}
	}
	return "YES"
}

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 main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		_ = readArrInt(input)
		arr := readArrInt(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		}
	}
	if len(positives) == 0 && len(negatives) == 0 {
		return "YES"
	} else if len(arr) == 3 && arr[0]+arr[1]+arr[2] == 0 {
		return "YES"
	}
	return "NO"
}

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 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 main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		m[val] = struct{}{}
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[tmp[i]+tmp[j]+tmp[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

package main

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

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 main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		m[val] = struct{}{}
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[arr[i]+arr[j]+arr[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

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 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 gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; 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 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 vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
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 ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
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
	// If the array has 3 positive numbers or 3 negative numbers, then it cannot be closed
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		z := 0; nz := ia(0); for _,a := range A { if a == 0 { z++ } else { nz = append(nz,a) } }
		good := true
		if len(nz) > 4 {
			good = false
		} else {
			sb := make(map[int64]bool)
			if z > 0 { sb[0] = true }
			for _,x := range nz { sb[int64(x)] = true }
			if z > 0 {
				for i:=0;i<len(nz);i++ {
					for j:=i+1;j<len(nz);j++ {
						s := int64(i)+int64(j)
						if !sb[s] { good = false }
					}
				}
			}
			for i:=0;i<len(nz);i++ {
				for j:=i+1;j<len(nz);j++ {
					for k:=j+1;k<len(nz);k++ {
						s := int64(i)+int64(j)+int64(k)
						if !sb[s] { good = false }
					}
				}
			}
		}
		if good { fmt.Fprintln(wrtr,"YES") } else { fmt.Fprintln(wrtr,"NO") }
	}
}


package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int
	var curQueueSize int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
			curQueueSize++
		}
	}

	for i := 0; i < curQueueSize; i++ {
		if data[queue[i]][0] == 0 {
			continue
		}

		if data[queue[i]][0] == 1 {
			data[queue[i]][0]--
			data[data[queue[i]][1]][0]--
			data[data[queue[i]][1]][1] ^= queue[i]
			queue = append(queue, data[queue[i]][1])
			curQueueSize++

			result := [2]int{queue[i], data[queue[i]][1]}
			results = append(results, result)
		}
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}

package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
		}
	}

	for len(queue) > 0 {
		index := queue[0]

		if data[index][0] == 0 {
			queue = queue[1:len(queue)]
			continue
		}

		if data[index][0] == 1 {
			data[index][0]--
			data[data[index][1]][0]--
			data[data[index][1]][1] ^= index
			queue = append(queue, data[index][1])

			result := [2]int{index, data[index][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int

	for i := 0; i < n; i++ {
		fmt.Scan(&data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
		}
	}

	for len(queue) > 0 {
		if data[queue[0]][0] == 0 {
			queue = queue[1:len(queue)]
			continue
		}

		if data[queue[0]][0] == 1 {
			data[data[queue[0]][1]][0]--
			data[data[queue[0]][1]][1] ^= queue[0]
			queue = append(queue, data[queue[0]][1])

			result := [2]int{queue[0], data[queue[0]][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
	}

	fmt.Println(len(results))

	for i := 0; i < len(results); i++ {
		fmt.Println(results[i][0], results[i][1])
	}
}

package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int
	var curQueueSize int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
			curQueueSize++
		}
	}

	for i := 0; i < curQueueSize; i++ {
		if data[queue[i]][0] == 0 {
			queue = queue[1:len(queue)]
			curQueueSize--
			continue
		}

		if data[queue[i]][0] == 1 {
			data[queue[i]][0]--
			data[data[queue[i]][1]][0]--
			data[data[queue[i]][1]][1] ^= queue[i]
			queue = append(queue, data[queue[i]][1])
			curQueueSize++

			result := [2]int{queue[i], data[queue[i]][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
		curQueueSize--
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}


package main

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

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

	var T, q, l, r int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s, &q)
		sum := make([]int, len(s)+1)
		for i, b := range s {
			sum[i+1] = sum[i]
			if b < 42 {
				sum[i+1] += i&1<<1 - 1
			}
		}
		for ; q > 0; q-- {
			Fscan(in, &l, &r)
			Fprintln(out, abs(sum[r]-sum[l-1]))
		}
	}
}

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func abs(x int) int {
  if x < 0 {
    return -x
  }
  return x
}

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

  var t int
  for fmt.Fscan(reader, &t); t > 0; t-- {
    var s string
    fmt.Fscan(reader, &s)
    n := len(s)
    pref := make([]int, n+1)
    pref[0] = 0;
    for i:= 0; i < n; i++ {
      pref[i+1] = pref[i]
      if s[i] == '[' || s[i] == ']' {
        if i&1 > 0 {
          pref[i+1]++
        } else {
          pref[i+1]--
        }
      }
    }
    var q int
    fmt.Fscan(reader, &q)
    for ; q > 0; q-- {
      var l, r int
      fmt.Fscan(reader, &l, &r)
      fmt.Fprint(writer, abs(pref[r]-pref[l-1]), "\n")
    }
  }
}


// 34B-mic
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, m int
    a := make([]int, 1001)
    fmt.Scan(&n, &m)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sum := 0
    sort.Sort(sort.IntSlice(a))
    for j := 0; j < m; j++ {
        if a[j] >= 0 {
            break
        }
        sum += a[j]
    }
    fmt.Println(-1 * sum)
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sort.Ints(a)
    ans := 0
    for i := 0; (i < n) && (a[i] < 0) && (m > 0); i++ {
        ans += (-a[i])
        m--
    }
    fmt.Println(ans)
}

package main

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

func getInput() (int, int, []int) {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  scanner.Scan()
  n, _ := strconv.Atoi(scanner.Text())
  scanner.Scan()
  m, _ := strconv.Atoi(scanner.Text())
  arr := make([]int,n);
  for i:=0; i<n; i++ {
    scanner.Scan()
    v, _ := strconv.Atoi(scanner.Text());
    arr[i] = v
  }
  return  n, m, arr
}

func main() {
 _, m, arr := getInput()
 sort.Ints(arr)
 sum := 0;
 for i:=0; i<m && arr[i]<0 ; i++ {
    sum += arr[i];
 }
 fmt.Println(-sum)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

func main(){
	var n,m int
	fmt.Scanf("%d %d\n",&n,&m)
	a := make([]int,n)
	for i:= range a{
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var earn int
	for i:=0;i<m;i++{
		if a[i]<0{
			earn+=a[i]
		}
	}
	fmt.Println(math.Abs(float64(earn)))
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, m int
	fmt.Scan(&t, &m)

	tvArray := make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Scan(&tvArray[i])
	}

	sort.Ints(tvArray)
	counter := 0
	money := 0
	for ; m > 0; m-- {
		if tvArray[counter] <= 0 {
			money += tvArray[counter]
		}
		counter++
	}

	if money > 0 {
		fmt.Print(0)
	} else {
		fmt.Print(-money)
	}

}

package main
import (
	"fmt"
	"sort"
)
func main() {
	var n,m int
	a:=0
	fmt.Scan(&n,&m)
	v:=make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&v[i])
	}
	sort.Ints(v)
	for i:=0;i<m && v[i]<0;i++ {
		a-=v[i]
	}
	fmt.Println(a)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	inputs := make([]int, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&inputs[i])
	}
	sort.Ints(inputs)
	ans := 0
	for i:=0; i<m; i++ {
		if inputs[i] < 0 {
			ans -= inputs[i]
		} else {
			break
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
	var n, m int
	if _, err := fmt.Scanf("%d %d\n", &n, &m); err != nil {
		return
	}

	array := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		array[i] = a
	}

	merge_sort(array, 0, n-1)

	earn := 0
	for i := 0; i < m; i++ {
		if array[i] < 0 {
			earn -= array[i]
		} else {
			break
		}
	}

	fmt.Println(earn)
}

func merge(buffer []int, start, middle, end int) {
	sorted := make([]int, end-start+1)

	i := start
	j := middle + 1
	k := 0
	for i <= middle && j <= end {
		if buffer[i] <= buffer[j] {
			sorted[k] = buffer[i]
			i++
		} else {
			sorted[k] = buffer[j]
			j++
		}
		k++
	}
	for i <= middle {
		sorted[k] = buffer[i]
		k++
		i++
	}
	for j <= end {
		sorted[k] = buffer[j]
		k++
		j++
	}

	i = start
	k = 0
	for i <= end {
		buffer[i] = sorted[k]
		i++
		k++
	}
}

func merge_sort(buffer []int, start, end int) {
	if end > start {
		middle := (end + start) / 2
		merge_sort(buffer, start, middle)
		merge_sort(buffer, middle+1, end)
		merge(buffer, start, middle, end)
	}
}

// cf34b project main.go
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	sort.Ints(a)
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

func main(){
	var n,m int
	fmt.Scanf("%d %d\n",&n,&m)
	a := make([]int,n)
	for i:= range a{
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var earn int
	for i:=0;i<m;i++{
		earn+=a[i]
	}
	fmt.Println(math.Abs(float64(earn)))
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	sort.Ints(a)
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m, s int
	fmt.Scan(&n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}

	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i]
	}
	fmt.Println(s)
}

// cf34b project main.go
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				tmp := a[j]
				a[j] = a[j+1]
				a[j+1] = tmp
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
		if a[i] == 7 {
			fmt.Println(a)
		}
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	fmt.Println(a)
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s, a)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

// cf34b project main.go
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	if m == 2 {
		fmt.Println(a)
	}
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
	s := 0
	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
)

func main() {
	var n, m, s int
	fmt.Scan(&n, &m)
	var a []int
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scanf("%d", &ai)
		a = append(a, ai)
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < i; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}

	for i := 0; i < m && a[i] < 0; i++ {
		s += a[i] * (-1)
	}
	fmt.Println(s)
}


package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	t := scanInt()

	for i := 0; i < t; i++ {
		n := scanInt()
		if n>2 && n%2==1 {
			fmt.Fprint(wr,"7")
			n-=3
		}
		for j := 0; j < n/2; j++ {
			fmt.Fprint(wr,"1")
		}
		fmt.Fprintln(wr)
		wr.Flush()
	}
}

package main

import (
	"fmt"
	"strings"
)

func FindNumber(segments int32) string {
	res := make([]string, 0, 100)
	ones := int(segments) / 2
	sevens := int(segments) % 2

	if sevens == 1 {
		ones -= 1
	}

	for i := 0; i < sevens; i++ {
		res = append(res, "7")
	}

	for i := 0; i < ones; i++ {
		res = append(res, "1")
	}

	return strings.Join(res, "")
}

func main() {
	var t, n int32

	fmt.Scanf("%d\n", &t)

	for i := int32(0); i < t; i++ {
		fmt.Scanf("%v\n", &n)
		fmt.Printf("%v\n", FindNumber(n))
	}
}

package main

import (
	"fmt"
	"strings"
)

type pair struct {
	s, o int
}

func main() {
	var t int
	fmt.Scan(&t)
	ans := make([]pair, 0)
	for i := 0; i < t; i++ {
		var n int
		var p pair
		fmt.Scan(&n)
		if n == 2 {
			p.o = 1
		} else if n == 3 {
			p.s = 1
		} else {
			p.o = 1
			n -= 2
			for n >= 2 {
				// fmt.Println("n", n)
				if n == 3 {
					p.s = 1
				} else {
					p.o++
				}
				n -= 2
			}
		}
		ans = append(ans, p)
	}
	for i := 0; i < len(ans); i++ {
		fmt.Println(strings.Repeat("7", ans[i].s) + strings.Repeat("1", ans[i].o))
	}
}

package main

import "fmt"

func main() {
	var q int
	fmt.Scan(&q)

	for i := 0; i < q; i++ {
		var n int
		fmt.Scan(&n)

		ones := n / 2

		if n%2 == 1 {
			fmt.Print("7")
			ones--
		}

		for j := 0; j < ones; j++ {
			fmt.Print("1")
		}

		fmt.Println()
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t, n int
	fmt.Fscanln(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscanln(reader, &n)
		var result strings.Builder
		ones_count := n / 2
		if n%2 == 1 {
			result.WriteString("7")
			ones_count -= 1
		}
		for ; ones_count > 0; ones_count-- {
			result.WriteString("1")
		}
		fmt.Fprintln(writer, result.String())
	}
}

package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		if n&1 == 0 {
			Fprintln(out, Repeat("1", n/2))
		} else {
			Fprintln(out, "7"+Repeat("1", (n-3)/2))
		}
	}
}

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

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

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

}

func solve(n int) string {
	res := make([]byte, 0, n/2)
	if n%2 == 1 {
		res = append(res, '7')
		n -= 3
	}
	for i := 0; i < n/2; i++ {
		res = append(res, '1')
	}
	return string(res)
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n := ScanInt64()
		r := []rune{}

		if n % 2 != 0 {
		    r = append(r, '7')
		    for i := int64(1); i < n/2; i++ {
    		    r = append(r, '1')
    		}
		} else {
		    for i := int64(0); i < n/2; i++ {
		         r = append(r, '1')
		    }
		}

        O <- string(r)
	}
	close(O)
	oWg.Wait()
}

func IsPrime(value int) bool {
	for i := 2; i <= int(math.Floor(float64(value)/2)); i++ {
		if value%i == 0 {
			return false
		}
	}
	return value > 1
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var Pl func(a ...interface{}) (n int, err error)

func init() {
	Pl = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int64) []int64 {
	length := int(n)
	arr := make([]int64, n)
	for i := 0; i < length; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    noEx := 0
    fmt.Fscan(in, &noEx)
    for ; noEx>0; noEx-- {
        n := 0
        fmt.Fscan(in, &n)
        var s []string
        for n > 0 {
            if n == 2 {s = append(s, "1"); break}
            if n == 3 {s = append(s, "7"); break}
            s = append(s, "1")
            n -= 2
        }
        for lo,hi:=0,len(s)-1; lo<hi; lo++ {
            s[lo], s[hi] = s[hi], s[lo]
            hi--
        }
        fmt.Fprint(out, strings.Join(s, "") + "\n")
    }
}

package main

import "fmt"

func abs(a int) int{
	if a < 0{
		return -a
	} else{
		return a
	}
}

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

func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0;i<t ; i++ {
		var n int
		fmt.Scanln(&n)
		if n%2 > 0 {
			fmt.Print("7")
			n -= 3
		}
		for j:=0;j<n/2 ; j++ {
			fmt.Print("1")
		}
		fmt.Println()
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	ans := make([]string, t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)
		if n%2 == 0 {
			ans[i] = strings.Repeat("1", n/2)
		} else {
			ans[i] = "7" + strings.Repeat("1", (n-3)/2)
		}
	}
	fmt.Fprintln(w, strings.Join(ans, "\n"))
}

// For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the 𝑛 days of summer. On the 𝑖-th day, 𝑎𝑖 millimeters of rain will fall. All values 𝑎𝑖 are distinct.

// The mayor knows that citizens will watch the weather 𝑥 days before the celebration and 𝑦 days after. Because of that, he says that a day 𝑑 is not-so-rainy if 𝑎𝑑 is smaller than rain amounts at each of 𝑥 days before day 𝑑 and and each of 𝑦 days after day 𝑑. In other words, 𝑎𝑑<𝑎𝑗 should hold for all 𝑑−𝑥≤𝑗<𝑑 and 𝑑<𝑗≤𝑑+𝑦. Citizens only watch the weather during summer, so we only consider such 𝑗 that 1≤𝑗≤𝑛.

// Help mayor find the earliest not-so-rainy day of summer.

// Input
// The first line contains three integers 𝑛, 𝑥 and 𝑦 (1≤𝑛≤100000, 0≤𝑥,𝑦≤7) — the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after.

// The second line contains 𝑛 distinct integers 𝑎1, 𝑎2, ..., 𝑎𝑛 (1≤𝑎𝑖≤109), where 𝑎𝑖 denotes the rain amount on the 𝑖-th day.

// Output
// Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.

package main

import(
	"fmt"
)

func main() {
	var t int
	var n int
	fmt.Scanf("%d", &t)
	for i := 0; i < t;  i++ {
	fmt.Scanf("\n")
		fmt.Scanf("%d", &n)
		var maxNo = n/2
		var remaining = n%2
		var first int
		if remaining == 1 {
			first = 7
		}else {
			first = 1
		}
		fmt.Print(first)
		for i := 0; i < maxNo - 1; i++ {
			fmt.Print(1)
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
	"strings"
)

func FindNumber(segments int32) string {
	res := make([]string, 0, 100)
	ones := int(segments) / 2
	sevens := int(segments) % 2

	if sevens == 1 {
		ones -= 1
	}

	for i := 0; i < ones; i++ {
		res = append(res, "1")
	}

	for i := 0; i < sevens; i++ {
		res = append(res, "7")
	}

	return strings.Join(res, "")
}

func main() {
	var t, n int32

	fmt.Scanf("%d\n", &t)

	for i := int32(0); i < t; i++ {
		fmt.Scanf("%v\n", &n)
		fmt.Printf("%v\n", FindNumber(n))
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	ans := make([]int, 0)
	for i := 0; i < t; i++ {
		var n, a int
		fmt.Scan(&n)
		if n == 2 {
			a = 1
		} else if n == 3 {
			a = 7
		} else {
			a = 1
			n -= 2
			for n >= 2 {
				// fmt.Println("n", n)
				if n == 3 {
					a = a*10 + 7
				} else {
					a = a*10 + 1
				}
				n -= 2
			}
		}
		ans = append(ans, a)
	}
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		if n&1 == 0 {
			Fprintln(out, Repeat("1", n/2))
		} else {
			Fprintln(out, Repeat("1", (n-3)/2)+"7")
		}
	}
}

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

package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    noEx := 0
    fmt.Fscan(in, &noEx)
    for ; noEx>0; noEx-- {
        n := 0
        fmt.Fscan(in, &n)
        var s []string
        for n > 0 {
            if n == 2 {s = append(s, "1"); break}
            if n == 3 {s = append(s, "7"); break}
            s = append(s, "1")
            n -= 2
        }
        fmt.Fprint(out, strings.Join(s, "") + "\n")
    }
}

package main

import "fmt"

func abs(a int) int{
	if a < 0{
		return -a
	} else{
		return a
	}
}

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

func main() {
	var t int
	fmt.Scanln(&t)
	for i := 0;i<t ; i++ {
		var n int
		fmt.Scanln(&n)
		if n <= 20{
			if n%2 > 0 {
				fmt.Print("7")
				n -= 3
			}
			for j:=0;j<n/2 ; j++ {
				fmt.Print("1")
			}
			fmt.Println()
		} else if n >20 && n <60{
			m := (n-24)/4
			for j:=0;j<m ;j++  {
				fmt.Print("9")
			}
			k := (n-24)%4
			for j:=0;j<k ;j++  {
				fmt.Print("7")
			}
			for j:=0;j<n-m-k ;j++  {
				fmt.Print("1")
			}
			fmt.Println()
		} else{
			for j:=0;j<10;j++  {
				fmt.Print("9")
			}
			fmt.Println()
		}
	}
}

// For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the 𝑛 days of summer. On the 𝑖-th day, 𝑎𝑖 millimeters of rain will fall. All values 𝑎𝑖 are distinct.

// The mayor knows that citizens will watch the weather 𝑥 days before the celebration and 𝑦 days after. Because of that, he says that a day 𝑑 is not-so-rainy if 𝑎𝑑 is smaller than rain amounts at each of 𝑥 days before day 𝑑 and and each of 𝑦 days after day 𝑑. In other words, 𝑎𝑑<𝑎𝑗 should hold for all 𝑑−𝑥≤𝑗<𝑑 and 𝑑<𝑗≤𝑑+𝑦. Citizens only watch the weather during summer, so we only consider such 𝑗 that 1≤𝑗≤𝑛.

// Help mayor find the earliest not-so-rainy day of summer.

// Input
// The first line contains three integers 𝑛, 𝑥 and 𝑦 (1≤𝑛≤100000, 0≤𝑥,𝑦≤7) — the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after.

// The second line contains 𝑛 distinct integers 𝑎1, 𝑎2, ..., 𝑎𝑛 (1≤𝑎𝑖≤109), where 𝑎𝑖 denotes the rain amount on the 𝑖-th day.

// Output
// Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.

package main

import(
	"fmt"
)

func main() {
	var t int
	var n int
	fmt.Scanf("%d", &t)
	for i := 0; i < t;  i++ {
	fmt.Scanf("\n")
		fmt.Scanf("%d", &n)
		var maxNo = n/2
		var remaining = n%2
		var first int
		if remaining == 1 {
			first = 7
		}else {
			first = 1
		}
		fmt.Print(first)
		for i := 0; i < maxNo - 1; i++ {
			fmt.Print(1)
		}
	}
}

// For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the 𝑛 days of summer. On the 𝑖-th day, 𝑎𝑖 millimeters of rain will fall. All values 𝑎𝑖 are distinct.

// The mayor knows that citizens will watch the weather 𝑥 days before the celebration and 𝑦 days after. Because of that, he says that a day 𝑑 is not-so-rainy if 𝑎𝑑 is smaller than rain amounts at each of 𝑥 days before day 𝑑 and and each of 𝑦 days after day 𝑑. In other words, 𝑎𝑑<𝑎𝑗 should hold for all 𝑑−𝑥≤𝑗<𝑑 and 𝑑<𝑗≤𝑑+𝑦. Citizens only watch the weather during summer, so we only consider such 𝑗 that 1≤𝑗≤𝑛.

// Help mayor find the earliest not-so-rainy day of summer.

// Input
// The first line contains three integers 𝑛, 𝑥 and 𝑦 (1≤𝑛≤100000, 0≤𝑥,𝑦≤7) — the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after.

// The second line contains 𝑛 distinct integers 𝑎1, 𝑎2, ..., 𝑎𝑛 (1≤𝑎𝑖≤109), where 𝑎𝑖 denotes the rain amount on the 𝑖-th day.

// Output
// Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.

package main

import(
	"fmt"
)

func main() {
	var t int
	var n int
	fmt.Scanf("%d", &t)
	for i := 0; i < t;  i++ {
		fmt.Scanf("%d", &n)
		var maxNo = n/2
		var remaining = n%2
		var first int
		if remaining == 1 {
			first = 7
		}else {
			first = 1
		}
		fmt.Print(first)
		for i := 0; i < maxNo - 1; i++ {
			fmt.Print(1)
		}
	}
}