package main

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

type CF1646B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1646B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1646B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1646B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1646B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1646B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1646B
Date: 2/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1646/B
Problem: CF1646B
**/
func (in *CF1646B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}
		sort.Ints(arr)
		ans := false
		a := int64(arr[0] + arr[1])
		b := int64(arr[n-1])
		i, j := 2, n-2

		if a < b {
			ans = true
		}

		for a >= b && i < j && !ans {

			a += int64(arr[i])
			b += int64(arr[j])
			j--
			i++
			if a < b {
				ans = true
			}
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func NewCF1646B(r *bufio.Reader) *CF1646B {
	return &CF1646B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1646B(bufio.NewReader(os.Stdin)).Run()
}

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 i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int64, 0, n)
		for j := 0; j < n; j++ {
			var num int64
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		l, r := 1, n-1
		lsum := arr[0]
		rsum := int64(0)
		flag := false
		for l < r {
			lsum, rsum = lsum + arr[l], rsum + arr[r]
			if lsum < rsum {
				flag = true
				break
			}
			l, r = l + 1, r - 1
		}
		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

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

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

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

package main

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

// B. Quality vs Quantity

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var bsum, rsum, bcount, rcount int64 = int64(a[0]), int64(a[n-1]), 1, 1

	// limits the sum on the for loop
	j := n - 1

	// if it has found a way to paint the numbers
	found := false

	for i := 1; i <= j; i++ {
		bsum += int64(a[i])
		if bsum >= rsum && j-1 > i {
			//println(bsum, ">=", rsum, i, j)
			j -= 1
			rsum += int64(a[j])
			rcount++
		}
		bcount++

		if bsum < rsum && bcount > rcount {
			found = true
			break
		}
	}

	//println(bsum, rsum, bcount, rcount)

	if found {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

//}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

func Solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}
	sort.Ints(a)
	sumRed, sumBlue := int64(0), int64(0)
	for i := 0; i <= (n-1)/2; i++ {
		sumBlue += int64(a[i])
	}
	for i := 0; i < (n-1)/2; i++ {
		sumRed += int64(a[n-1-i])
	}
	if sumRed > sumBlue {
		println("YES")
	} else {
		println("NO")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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 readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	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
}

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

	defer out.Flush()

	n := readInt(in)

	for i := 0; i < n; i++ {
		_ = readInt(in)

		input := readArrInt64(in)

		res := Solve(input)

		fmt.Fprintf(out, "%s\n", res)
	}
}

func Solve(in []int64) string {
	sort.Slice(in, func(i, j int) bool { return in[i] < in[j] })

	if in[len(in)-1] > in[0]+in[1] {
		return fmt.Sprint("YES")
	}

	sumLess := in[0] + in[1]
	sumOver := in[len(in)-1]
	i := 2
	j := 2

	for i < len(in)-j {
		sumOver += in[len(in)-j]
		sumLess += in[i]

		if sumOver > sumLess {
			return fmt.Sprint("YES")
		}

		i++
		j++
	}

	return fmt.Sprint("NO")
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "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 i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		sort.Ints(a)
		var f,s,last int = a[0],0,0
		for j:=n-1;j>=n/2+1;j--{
			f+=a[n-j]
			s+=a[j]
			if s-f > 0 {
				fmt.Fprintln(out,"YES")
				goto out
			}
			if f-s >= last && j!=n-1 {
				fmt.Fprintln(out,"NO")
				goto out
			}
			last=f-s
		}
		fmt.Fprintln(out,"NO")
		out:
	}
}

package main
import("bufio";."fmt";"os";"sort")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var T, n int
o:  for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		for l, r, s, t := 1, n-1, int64(a[0]), int64(0); l < r; l++ {
			s += int64(a[l])
			t += int64(a[r])
			if s < t {
				Println("YES")
				continue o
			}
			r--
		}
		Println("NO")
	}
}

package main

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

func summ(array []int64) int64 {
	var sum int64 = 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int64, n)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = int64(number)
			//variables = append(variables, number)
		}

		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		flag := false
		if len(variables) > 2 {
			var prefixSum int64 = 0
			var postfiSum int64 = variables[len(variables)-1]
			if prefixSum > postfiSum {
				answers = append(answers, "YES")
				continue
			}
			for j := 0; j < int(len(variables)/2); j++ {
				prefixSum += variables[j]
				postfiSum += variables[len(variables)-1-(j+1)]
				if prefixSum > postfiSum {
					flag = true
					break
				}
			}
		}

		// 19 18 16 16 15 15 15 14 14 10

		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Println(r)
	}
}

package main

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

/*
4
7
9 0 5 2 1 8 7
4
1 1 1 1
4
1 1 2 2
5
1 1 3 3 3
---
YES 0 1 2 5 7 8 9
NO
NO
YES
========
4
3
1 2 3
3
0 1 1
7
5 1 4 6 5 8 4
6
1 1 2 3 3 3
---
NO
NO
YES 1 4 4 5 5 6 8
YES
========
1
6
2 3 3 3 4 5
---
YES 4+5 (9) > 2+3+3 (8)
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int64, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

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

	ans := "NO"

	redSum := int64(0)
	blueSum := a[0]

	for i, j := 1, n-1; i < j; i, j = i+1, j-1 {
		redSum += a[j]
		blueSum += a[i]

		if redSum > blueSum {
			ans = "YES"
			break
		}
	}

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int64) int64 {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

var s [2e5 + 5]int

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n := read()
		for i := 1; i <= n; i++ {
			s[i] = read()
		}
		sort.Ints(s[1 : n+1])
		l, r := 2, n
		str := "NO"
		del := s[n] - s[2] - s[1]
		for l < r {
			if del > 0 {
				str = "YES"
				break
			}
			l++
			r--
			del += s[r] - s[l]
		}
		Fprintln(out, str)
	}
}

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

package main

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

func solve(scanner *bufio.Scanner) {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	arr := make([]int, 0)
	for i := 0; i < n; i++ {
		scanner.Scan()
		cur, _ := strconv.Atoi(scanner.Text())
		arr = append(arr, cur)
	}
	sort.Ints(arr)
	sumL, sumR := int64(0), int64(0)
	l, r := 0, len(arr)-1
	cntL, cntR := 0, 0
	for l <= r {
		if cntL <= cntR {
			sumL += int64(arr[l])
			l++
			cntL++
		} else {
			if sumR > sumL && cntR > 0 {
				fmt.Println("YES")
				return
			} else {
				sumR += int64(arr[r])
				r--
				cntR++
			}
		}
	}

	if sumR > sumL && cntR < cntL {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

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

}

package main

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

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

func main() {
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(in, &a[i])
		}
		sort.Ints(a)

		bluecnt, redcnt := 1, 1
		bluesum, redsum := int64(a[0]), int64(a[n-1])
		for bluecnt+redcnt <= n && (bluecnt <= redcnt || bluesum >= redsum) {
			if bluecnt <= redcnt {
				bluesum += int64(a[bluecnt])
				bluecnt++
			} else {
				redcnt++
				redsum += int64(a[n-redcnt])
			}
		}
		if bluecnt+redcnt <= n {
			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)

		arr := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})

		bp, rp := 0, n-1
		var bs, rs int64
		bc, rc := 0, 0
		var f bool
		for rp-bp > 0 {
			if rc <= bc && rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			} else if bs <= rs && bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			} else if rs > bs && rc < bc {
				f = true
				break
			} else {
				break
			}
		}

		if !f && bp <= rp {
			if rs <= bs {
				rs += arr[rp]
				rc++
			} else if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func summ(array []int64) int64 {
	var sum int64 = 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int64, n)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = int64(number)
			//variables = append(variables, number)
		}

		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		var sum int64
		sum = summ(variables)
		var prefixSum int64 = 0
		var countLeft int64 = 0
		var countRight int64 =  int64(len(variables))

		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Println(r)
	}
}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	fmt.Println(t)
	//fmt.Println(t)
	var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)
		fmt.Println(n)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = number
			//variables = append(variables, number)
		}
		fmt.Println(variables)
		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	//for _, r := range answers {
	//	fmt.Println(r)
	//}
}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)

		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = number
			//variables = append(variables, number)
		}
		fmt.Println(variables)
		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	//for _, r := range answers {
	//	fmt.Println(r)
	//}
}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)

		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = number
			//variables = append(variables, number)
		}
		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Println(r)
	}
}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	//var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		numbers := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)

		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = number
			//variables = append(variables, number)
		}
		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	//var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//fmt.Println(t)
	//var answers []string

	for i := 0; i < t; i++ {
		//var n int
		b := ReadLine(inputReader)
		//fmt.Println(b)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)

		numbers := ReadLine(inputReader)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			//fmt.Println(j)
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables[j] = number
			//variables = append(variables, number)
		}
		//fmt.Println(variables)
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//var answers []string

	for i := 0; i < t; i++ {
		var n int
		b := ReadLine(inputReader)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)
		numbers := ReadLine(inputReader)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables = append(variables, number)
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	var t int
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	//var answers []string

	for i := 0; i < t; i++ {
		var n int
		b := ReadLine(inputReader)
		n, err := strconv.Atoi(b)
		if err != nil {
			return
		}
		variables := make([]int, n)
		numbers := ReadLine(inputReader)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables = append(variables, number)
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum+r > sum-r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var answers []string

	for i := 0; i < t; i++ {
		inputReader := bufio.NewReader(os.Stdin)
		var n int
		fmt.Scanf("%d\n", &n)
		variables := make([]int, n)
		numbers := ReadLine(inputReader)
		s := strings.Split(numbers, " ")
		for j := 0; j < n; j++ {
			number, err := strconv.Atoi(s[j])
			if err != nil {
				return
			}
			variables = append(variables, number)
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Print(r, "\n")
	}

}

package main

import (
	"fmt"
	"sort"
)

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var answers []string
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		variables := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &variables[j])
		}
		fmt.Println()
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Print(r, "\n")
	}

}

package main

import (
	"fmt"
	"sort"
)

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var answers []string
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		variables := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &variables[j])
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Print(r, "\n")
	}

}

package main

import (
	"fmt"
	"sort"
)

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var answers []string
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		variables := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Scan(&variables[j])
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Print(r, "\n")
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func main() {
	var t int
	fmt.Fscan(os.Stdin, &t)
	var answers []string
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		variables := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Scan(&variables[j])
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Print(r, "\n")
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

func main() {
	var t int
	fmt.Fscan(os.Stdin, &t)
	var answers []string
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		variables := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Scan(&variables[j])
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Println(r)
	}

}

package main

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

func summ(array []int) int {
	sum := 0
	for _, r := range array {
		sum += r
	}
	return sum
}

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		variables := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&variables[j])
		}
		sort.Slice(variables, func(i, j int) bool {
			return variables[i] > variables[j]
		})
		sum := summ(variables)
		prefixSum := 0
		countLeft := 0
		countRight := len(variables)
		flag := false
		for _, r := range variables {
			if (prefixSum + r > sum - r) && (countLeft+1 < countRight-1) {
				flag = true
				break
			} else {
				prefixSum += r
				sum -= r
				countLeft += 1
				countRight -= 1
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var bsum, rsum, bcount, rcount int64 = int64(a[0]), int64(a[n-1]), 1, 1

	// limits the sum on the for loop
	j := n - 1

	// if it has found a way to paint the numbers
	found := false

	for i := 1; i <= j; i++ {
		bsum += int64(a[i])
		if bsum >= rsum && j-1 > i {
			j -= 1
			rsum += int64(a[j])
			rcount++
		}
		bcount++

		if bsum < rsum && bcount > rcount {
			found = true
			break
		}
	}

	println(bsum, rsum, bcount, rcount)

	if found {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var bsum, rsum, bcount, rcount int64 = int64(a[0]), int64(a[n-1]), 1, 1

	// limits the sum on the for loop
	j := n - 1

	// if it has found a way to paint the numbers
	found := false

	for i := 1; i <= j; i++ {
		bsum += int64(a[i])
		if bsum >= rsum && j-1 > i {
			println(bsum, ">=", rsum, i, j)
			j -= 1
			rsum += int64(a[j])
			rcount++
		}

		if bsum < rsum && bcount > rcount {
			found = true
			break
		}
	}

	println(bsum, rsum, bcount, rcount)

	if found {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var bsum, rsum, bcount, rcount int64 = int64(a[0]), int64(a[n-1]), 1, 1

	// limits the sum on the for loop
	j := n - 1

	// if it has found a way to paint the numbers
	found := false

	for i := 1; i <= j; i++ {
		bsum += int64(a[i])
		if bsum >= rsum {
			j -= 1
			rsum += int64(a[j])
			rcount++
		} else {
			bcount++
		}

		if bsum < rsum && bcount > rcount {
			found = true
			break
		}
	}

	if found {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var a0, a1, g int64 = int64(a[0]), int64(a[1]), int64(a[n-1])

	if a0+a1 < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var s, g, c int64 = int64(a[0]), int64(a[n-1]), 1

	for i := 1; i <= n-1; i++ {
		s += int64(a[i])
		if s > g {
			s -= int64(a[i])
			break
		}
		c++
		if c > 1 {
			break
		}
	}

	if c > 1 && s < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var s, g, c int64 = int64(a[0]), int64(a[n-1]), 0

	for i := 1; i <= n-1; i++ {
		s += int64(a[i])
		if s > g {
			s -= int64(a[i])
			break
		}
		c++
		if c > 1 {
			break
		}
	}

	if c > 1 && s < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	var s, g, c int64 = int64(a[0]), int64(a[n-1]), 0

	for i := 1; i <= n-1; i++ {
		s += int64(a[i])
		if s > g {
			s -= int64(a[i])
			break
		}
		c++
	}

	if c > 1 && s < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	g := a[n-1]
	s, c := a[0], 0

	for i := 1; i <= n-1; i++ {
		s += a[i]
		if s > g {
			s -= a[i]
			break
		}
		c++
	}

	if c > 1 && s < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main

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

// A. Square Counting

func solve() {

	var n int

	scanf("%d\n", &n)

	a := make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	g := a[n-1]
	s, c := 0, 0

	for i := 0; i < n; i++ {
		s += a[i]
		if s > g {
			s -= a[i]
			break
		}
		c++
	}

	if c > 1 && s < g {
		println("YES")
	} else {
		println("NO")
	}
}

func main() {

	var t int

	scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}

	writer.Flush()
}

// Constants

const (
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

func println(f ...interface{}) {
	fmt.Fprintln(writer, f...)
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		var f,s,last int = a[0],0,0
		for j:=n-1;j>=n/2+1;j--{
			f+=a[n-j]
			s+=a[j]
			if s-f > 0 {
				fmt.Fprintln(out,"YES")
				goto out
			}
			if f-s >= last && j!=n-1 {
				fmt.Fprintln(out,"NO")
				goto out
			}
			last=f-s
		}
		out:
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		var f,s,last int = a[0],0,0
		for j:=n-1;j>=n/2+1;j--{
			f+=a[n-j]
			s+=a[j]
			if s-f > 0 {
				fmt.Fprintln(out,"YES")
				goto out
			}
			if f-s >= last {
				fmt.Fprintln(out,"NO")
				goto out
			}
			last=f-s
		}
		out:
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
			sum+=a[j]
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		if a[0]+a[1] < a[n-1] {
			fmt.Fprintln(out,"YES")
			continue
		}
		if float64(sum)/float64(n) > float64(a[n/2]) {
			fmt.Fprintln(out,"YES")
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
			sum+=a[j]
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		if float64(sum)/float64(n) > float64(a[n/2]) {
			fmt.Fprintln(out,"YES")
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		var f,b int = a[0],0
		for j:=1;j<n;j++{
			f+=a[j]
			b+=a[n-1-j]
			if f < b {
				fmt.Fprintln(out,"YES")
				goto out
			}
		}
		fmt.Fprintln(out,"NO")
		out:
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		for j:=1;j<n;j++{
			if a[j] < a[j-1] {
				a[j],a[j-1] = a[j-1],a[j]
				j-=2
				if j<0{
					j=0
				}
			}
		}
		var sum1,sum2 int
		for j:=0;j<n/2+1;j++{
			sum1+=a[j]
		}
		for j:=n/2+1;j<n;j++{
			sum2+=a[j]
		}
		if sum2>sum1 {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		var f bool
		for rp-bp > 0 {
			if rc <= bc && rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			} else if bs <= rs && bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			} else if rs > bs && rc < bc {
				f = true
				break
			} else {
				break
			}
		}

		if !f && bp <= rp {
			if rs <= bs {
				rs += arr[rp]
				rc++
			} else if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		var f bool
		for rp-bp > 0 {
			if rc <= bc && rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			} else if bs <= rs && bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			} else if rs > bs && rc < bc {
				f = true
				break
			} else {
				break
			}
		}

		if !f && bp <= rp {
			if rs <= bs {
				rs += arr[rp]
				rc++
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		for rp-bp > 0 {
			if rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			}

			if rs > bs && rc < bc {
				break
			}
		}

		if bp <= rp {
			if rs <= bs {
				rs += arr[rp]
				rc++
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		for rp-bp > 0 {
			if rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			}

			if rs > bs && rc < bc {
				break
			}
		}

		if bp <= rp {
			if rs <= bs {
				rs += arr[rp]
				rc++
			} else if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		var f bool
		for rp-bp > 1 {
			if rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			}

			if rs > bs && rc < bc {
				f = true
				break
			}
		}

		if !f {
			if rs <= bs {
				rs += arr[rp]
				rc++
			} else if bc <= rc {
				bs += arr[bp]
				bc++
			}
		}

		if rs > bs && rc < bc {
			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)

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

		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		for rp-bp > 1 {
			if rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			}

			if rs > bs && rc < bc {
				break
			}
		}

		if rs <= bs {
			rs += arr[rp]
			rc++
		} else if bc <= rc {
			bs += arr[bp]
			bc++
		}

		if rs > bs && rc < bc {
			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)

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

		var f bool
		bp, rp := 0, n-1
		bs, rs := 0, 0
		bc, rc := 0, 0
		for rp-bp > 0 {
			if rs <= bs {
				rs += arr[rp]
				rc++
				rp--
			}

			if bc <= rc {
				bs += arr[bp]
				bc++
				bp++
			}

			if rs > bs && rc < bc {
				f = true
				break
			}
		}

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

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 i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		sort.Ints(arr)
		l, r := 1, n-1
		lsum := arr[0]
		rsum := 0
		flag := false
		for l < r {
			lsum, rsum = lsum + arr[l], rsum + arr[r]
			if lsum < rsum {
				flag = true
				break
			}
			l, r = l + 1, r - 1
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

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

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 i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		sort.Ints(arr)
		l, r := 1, n-1
		lsum := arr[0]
		rsum := 0
		flag := false
		for l < r {
			lsum, rsum = lsum + arr[l], rsum + arr[r]
			if lsum < rsum {
				flag = true
				break
			}
			l, r = l + 1, r - 1
		}
		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

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

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

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

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 i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		if len(arr) <= 2 {
			fmt.Fprintln(out, "NO")
			continue
		}
		sort.Ints(arr)
		l, r := 1, n-1
		lsum := arr[0]
		rsum := 0
		flag := false
		for l < r {
			lsum, rsum = lsum + arr[l], rsum + arr[r]
			if lsum < rsum {
				flag = true
				break
			}
			l, r = l + 1, r - 1
		}
		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

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

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

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

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 i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]int, 0, n)
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscan(in, &num)
			arr = append(arr, num)
		}
		// solve
		if len(arr) <= 2 {
			fmt.Fprintln(out, "NO")
			continue
		}
		sort.Ints(arr)
		if arr[0] + arr[1] < arr[n-1] {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

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

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

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

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

//}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

func Solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}
	sort.Ints(a)
	sumRed := int64(a[n-1])
	sumBlue := int64(a[1] + a[2])
	blueIdx := 3
	redIdx := n - 2
	for sumBlue >= sumRed {
		if blueIdx >= redIdx {
			println("NO")
			return
		}
		sumRed += int64(a[redIdx])
		sumBlue += int64(a[blueIdx])
		blueIdx++
		redIdx--
	}
	println("YES")
}

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

//}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

func Solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	sum := int64(0)
	for i := 0; i < n; i++ {
		scan(&a[i])
		sum += int64(a[i])
	}
	sort.Ints(a)
	sumRed := int64(0)
	for i := 0; i < (n-1)/2; i++ {
		sumRed += int64(a[n-1-i])
	}
	if sumRed*2 > sum {
		println("YES")
	} else {
		println("NO")
	}
}

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

//}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

func Solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	sum := int64(0)
	for i := 0; i < n; i++ {
		scan(&a[i])
		sum += int64(a[i])
	}
	sort.Ints(a)
	sumRed := int64(0)
	for i := 0; i < (n-1)/2; i++ {
		sumRed += int64(a[n-1-i])
	}
	fmt.Println(sumRed, sum)
	if sumRed*2 > sum {
		println("YES")
	} else {
		println("NO")
	}
}

package main

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

type CF1646B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1646B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1646B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1646B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1646B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1646B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1646B
Date: 2/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1646/B
Problem: CF1646B
**/
func (in *CF1646B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}
		sort.Ints(arr)
		ans := false
		a := arr[0] + arr[1]
		b := arr[n-1]
		i, j := 2, n-2

		if a < b {
			ans = true
		}

		for a >= b && i < j && !ans {

			a += arr[i]
			b += arr[j]
			j--
			i++
			if a < b {
				ans = true
			}
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func NewCF1646B(r *bufio.Reader) *CF1646B {
	return &CF1646B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1646B(bufio.NewReader(os.Stdin)).Run()
}

package main

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

type CF1646B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1646B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1646B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1646B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1646B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1646B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1646B
Date: 2/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1646/B
Problem: CF1646B
**/
func (in *CF1646B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}
		sort.Ints(arr)
		if arr[0]+arr[1] < arr[n-1] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func NewCF1646B(r *bufio.Reader) *CF1646B {
	return &CF1646B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1646B(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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 readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	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
}

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

	defer out.Flush()

	n := readInt(in)

	for i := 0; i < n; i++ {
		_ = readInt(in)

		input := readArrInt(in)

		res := Solve(input)

		fmt.Fprintf(out, "%s\n", res)
	}
}

func Solve(in []int) string {
	sort.Ints(in)

	if in[len(in)-1] > in[0]+in[1] {
		return fmt.Sprint("YES")
	}

	sumLess := in[0] + in[1]
	sumOver := in[len(in)-1]
	i := 2
	j := 2

	for i < len(in)-j {
		sumOver += in[len(in)-j]
		sumLess += in[i]

		if sumOver > sumLess {
			return fmt.Sprint("YES")
		}

		i++
		j++
	}

	return fmt.Sprint("NO")
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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 readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	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
}

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

	defer out.Flush()

	n := readInt(in)

	for i := 0; i < n; i++ {
		_ = readInt(in)

		input := readArrInt(in)

		res := Solve(input)

		fmt.Fprintf(out, "%s\n", res)
	}
}

func Solve(in []int) string {
	sort.Ints(in)

	if in[len(in)-1] > in[0]+in[1] {
		return fmt.Sprint("YES")
	} else {
		return fmt.Sprint("NO")
	}
}

package main
import("bufio";."fmt";"os";"sort")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var T, n int
o:  for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		for l, r, s, t := 1, n-1, a[0], 0; l < r; l++ {
			s += a[l]
			t += a[r]
			if s < t {
				Println("YES")
				continue o
			}
			r--
		}
		Println("NO")
	}
}

package main

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

/*
4
7
9 0 5 2 1 8 7
4
1 1 1 1
4
1 1 2 2
5
1 1 3 3 3
---
YES 0 1 2 5 7 8 9
NO
NO
YES
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	ans := "NO"

	if a[0]+a[1] < a[n-1] {
		ans = "YES"
	}

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int64) int64 {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}


package main
import "fmt"
import "os"
import "bufio"
import "sort"

type Node struct{
     x, y int
}

type Nodes []Node

func (s Nodes) Len() int {
    return len(s)
}

func (s Nodes) Less(i, j int) bool {
    return s[i].x+s[i].y > s[j].x+s[j].y
}

func (s Nodes) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

func main(){
    input := bufio.NewReader(os.Stdin)
    var n, r int;
    fmt.Fscanf(input, "%d%d\n", &n, &r)

    var a,b Nodes

    for i:=1; i<=n; i++ {
        var x, y int
        fmt.Fscanf(input, "%d%d\n", &x, &y)
        if y>=0 {
            a = append(a, Node{x, y})
        } else {
            b = append(b, Node{x, y})
        }
    }

    cnta := 0
    for update:=true; update; {
        update = false
        for i:=0; i<len(a); i++ {
            if a[i].x == 0 {
                continue
            }
            if r>=a[i].x {
                r += a[i].y
                cnta++; a[i].x = 0
                update = true
            }
        }
    }
    if cnta != len(a) {
        fmt.Println("NO")
        return
    }

    sort.Sort(b)
    /*
    for i:=0; i<len(b); i++ {
        fmt.Printf("%d %d\n", b[i].x, b[i].y)
    }
    */
    for i:=0; i<len(b); i++ {
        if r>=b[i].x {
            r += b[i].y
        } else {
            fmt.Println("NO")
            return
        }
    }
    if r<0 {
        fmt.Println("NO")
    } else {
        fmt.Println("YES")
    }
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1203F1(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	type pair struct{ x, y int }
	var n, r, a, b int
	var ls, rs []pair
	Fscan(in, &n, &r)
	ls = append(ls, pair{0, r})
	d := r
	for ; n > 0; n-- {
		Fscan(in, &a, &b)
		if b >= 0 {
			ls = append(ls, pair{a, b})
		} else {
			rs = append(rs, pair{a + b, a})
		}
		d += b
	}
	if d < 0 {
		Fprint(_w, "NO")
		return
	}
	rs = append(rs, pair{0, d})

	sort.Slice(ls, func(i, j int) bool { return ls[i].x < ls[j].x })
	sort.Slice(rs, func(i, j int) bool { return rs[i].x < rs[j].x })
	f := func(ps []pair) bool {
		s := 0
		for _, p := range ps {
			if s < p.x {
				return false
			}
			s += p.y
		}
		return true
	}
	if f(ls) && f(rs) {
		Fprint(_w, "YES")
	} else {
		Fprint(_w, "NO")
	}
}

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

package main
import "fmt"
import "os"
import "bufio"
import "sort"

type Node struct{
     x, y int
}

type Nodes []Node

func (s Nodes) Len() int {
    return len(s)
}

func (s Nodes) Less(i, j int) bool {
    return s[i].x+s[i].y > s[j].x+s[j].y
}

func (s Nodes) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

func main(){
    input := bufio.NewReader(os.Stdin)
    var n, r int;
    fmt.Fscanf(input, "%d%d\n", &n, &r)

    var a,b Nodes

    for i:=1; i<=n; i++ {
        var x, y int
        fmt.Fscanf(input, "%d%d\n", &x, &y)
        if y>=0 {
            a = append(a, Node{x, y})
        } else {
            b = append(b, Node{x, y})
        }
    }

    cnta := 0
    for update:=true; update; {
        update = false
        for i:=0; i<len(a); i++ {
            if a[i].x == 0 {
                continue
            }
            if r>=a[i].x {
                r += a[i].y
                cnta++; a[i].x = 0
                update = true
            }
        }
    }
    if cnta != len(a) {
        fmt.Println("NO")
        return
    }

    sort.Sort(b)
    /*
    for i:=0; i<len(b); i++ {
        fmt.Printf("%d %d\n", b[i].x, b[i].y)
    }
    */
    for i:=0; i<len(b); i++ {
        if r>=b[i].x {
            r += b[i].y
        } else {
            fmt.Println("NO")
            return
        }
    }
    fmt.Println("YES")
}


package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var caseNum int
	fmt.Fscan(r, &caseNum)
	for c := 0; c < caseNum; c++ {
		var n int
		fmt.Fscan(r, &n)
		arr := make([]int64, n+2)
		for i := 1; i <= n; i++ {
			fmt.Fscan(r, &arr[i])
		}
		solve1534B(arr)
	}
}
func solve1534B(arr []int64) {
	n := len(arr) - 2
	var res, ope int64 = 0, 0
	var flag bool = true
	for flag {
		flag = false
		for i := 1; i <= n; i++ {
			if arr[i] > arr[i-1] && arr[i] > arr[i+1] {
				tmp := max1534B(arr[i-1], arr[i+1])
				ope += arr[i] - tmp
				arr[i] = tmp
				flag = true
			}
		}
	}
	//calcu
	res += arr[1] + arr[n] + ope
	for i := 2; i <= n; i++ {
		res += max1534B(arr[i], arr[i-1]) - min1534B(arr[i], arr[i-1])
	}
	fmt.Println(res)
}
func max1534B(x, y int64) int64 {
	if x >= y {
		return x
	}
	return y
}
func min1534B(x, y int64) int64 {
	if x <= y {
		return x
	}
	return y
}

package main

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

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

func main() {
	defer out.Flush()
	solve := func(Case int) {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(in, &a[i])
		}
		a = prependInt(a, 0)
		a = append(a, 0)
		ans := int64(0)
		for i := 1; i <= n+1; i++ {
			if i != n+1 {
				mx := max(a[i-1], a[i+1])
				ans += int64(max(a[i]-mx, 0))
				a[i] -= max(a[i]-mx, 0)
			}
			ans += int64(absInt(a[i] - a[i-1]))
		}
		fmt.Fprintln(out, ans)
	}

	T := 1
	fmt.Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}
}
func absInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func prependInt(x []int, y int) []int {
	x = append(x, 0)
	copy(x[1:], x)
	x[0] = y
	return x
}

func powMod(x, y, mod int64) int64 {
	ans := int64(1)
	for y != 0 {
		if y&1 != 0 {
			ans = (ans * x) % mod
		}
		y = y >> 1
		x = (x * x) % mod
	}
	return ans
}
func max(x ...int) int {
	ans := math.MinInt32
	for i := range x {
		if x[i] > ans {
			ans = x[i]
		}
	}
	return ans
}

func min(x ...int) int {
	ans := math.MaxInt32
	for i := range x {
		if x[i] < ans {
			ans = x[i]
		}
	}
	return ans
}
func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func reverse(s []byte) []byte {
	a := []byte(s)
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var caseNum int
	fmt.Fscan(r, &caseNum)
	for c := 0; c < caseNum; c++ {
		var n int
		fmt.Fscan(r, &n)
		arr := make([]int, n+2)
		for i := 1; i <= n; i++ {
			fmt.Fscan(r, &arr[i])
		}
		solve1534B(arr)
	}
}
func solve1534B(arr []int) {
	n := len(arr) - 2
	res, ope := 0, 0
	var flag bool = true
	for flag {
		flag = false
		for i := 1; i <= n; i++ {
			if arr[i] > arr[i-1] && arr[i] > arr[i+1] {
				tmp := max1534B(arr[i-1], arr[i+1])
				ope += arr[i] - tmp
				arr[i] = tmp
				flag = true
			}
		}
	}
	//calcu
	res += arr[1] + arr[n] + ope
	for i := 2; i <= n; i++ {
		res += max1534B(arr[i], arr[i-1]) - min1534B(arr[i], arr[i-1])
	}
	fmt.Println(res)
}
func max1534B(x, y int) int {
	if x >= y {
		return x
	}
	return y
}
func min1534B(x, y int) int {
	if x <= y {
		return x
	}
	return y
}


package main

import (
	"fmt"
	. "math"
)

type point struct {
	x float64
	y float64
}

func main() {
	var n, k int
	var p1, p2 point

	distance := 0.0

	fmt.Scanf("%d %d\n", &n, &k)
	fmt.Scanf("%f %f\n", &p1.x, &p1.y)

	for i := 1; i < n; i++ {
		fmt.Scanf("%f %f\n", &p2.x, &p2.y)
		distance += Sqrt(Pow(p1.x-p2.x, 2) + Pow(p1.y-p2.y, 2))
		p1 = p2
	}

	fmt.Printf("%.9f", (distance/50.0)*float64(k))
}

package main

import (
    "fmt"
    "math"
)

func r(x1,y1,x2,y2 int) float64 {               // fungsi yang mengembalikan jarak antara titik (x1,y1) dan (x2,y2)
    dx, dy := float64(x1-x2), float64(y1-y2)    // membuat dx = selisih x1 dan x2 dan dy = selisih y1 dan y2 dalam float64
    return math.Sqrt(dx*dx + dy*dy)             // menggunakan rumus pythagoras untuk mencari jarak
}

func main() {
    var n,k int                     // membuat variabel n dan k dengan tipe data int
    var x,y [105]int                // membuat variabel x dan y dengan tipe data array of int dengan ukuran 105
    fmt.Scan(&n,&k)                 // menerima input n dan k
    var ans float64 = 0             // membuat variabel ans dengna tipe data float64 dengan nilai awal 0
    for i := 0; i < n; i++ {                            // looping sebanyak n kali
        fmt.Scan(&x[i],&y[i])                           // input xi dan yi
        if i != 0 { ans += r(x[i],y[i],x[i-1],y[i-1]) } // jika bukan titik pertama, tambahkan jarak titik sekarang
    }                                                   // terhadap titik sebelumnya ke dalam variabel ans
    fmt.Println(ans*float64(k)/50)                      // mencetak output hasil dari (ans*k)/50
}

package main

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

func main() {
	var n,k,a,b,c,d int
	var s float64
    	fmt.Scan(&n,&k)
    	n--
    	fmt.Scan(&a,&b)
	for i:=0;i<n;i++ {
	    	fmt.Scan(&c,&d)
		s+= math.Sqrt(float64((c-a)*(c-a)+(d-b)*(d-b)))
		a=c
		b=d
	}
	s=s*float64(k)/50
	fmt.Println(s)
}

package main

import (
    "fmt"
    "math"
)

func r(x1,y1,x2,y2 int) float64 {
    dx, dy := float64(x1-x2), float64(y1-y2)
    return math.Sqrt(dx*dx + dy*dy)
}

func main() {
    var n,k int
    var x,y [105]int
    fmt.Scan(&n,&k)
    var ans float64 = 0
    for i := 0; i < n; i++ {
        fmt.Scan(&x[i],&y[i])
        if i != 0 { ans += r(x[i],y[i],x[i-1],y[i-1]) }
    }
    fmt.Println(ans*float64(k)/50)
}

package main

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

func main() {
	var n,k,a,b,c,d int
	var s float64
	input := bufio.NewScanner(os.Stdin)
    	input.Split(bufio.ScanWords)
    	fmt.Scan(&n,&k)
    	n--
    	fmt.Scan(&a,&b)
	for i:=0;i<n;i++ {
		input.Scan();
       		aa, _ := strconv.Atoi(input.Text());
		c=aa
		input.Scan();
		bb, _ := strconv.Atoi(input.Text());
		d=bb
		s= math.Sqrt(float64((c-a)*(c-a)+(d-b)*(d-b)))
		a=c
		b=d
	}
	s=s*float64(k)/50
	fmt.Println(s)
}