Today, Yasser and Adel are at the shop buying cupcakes. There are $n$ cupcake types, arranged from $1$ to $n$ on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type $i$ is an integer $a_i$. There are both tasty and nasty cupcakes, so the tastiness can be positive, zero or negative.

Yasser, of course, wants to try them all, so he will buy exactly one cupcake of each type.

On the other hand, Adel will choose some segment $[l, r]$ $(1 \le l \le r \le n)$ that does not include all of cupcakes (he can't choose $[l, r] = [1, n]$) and buy exactly one cupcake of each of types $l, l + 1, \dots, r$.

After that they will compare the total tastiness of the cupcakes each of them have bought. Yasser will be happy if the total tastiness of cupcakes he buys is strictly greater than the total tastiness of cupcakes Adel buys regardless of Adel's choice.

For example, let the tastinesses of the cupcakes be $[7, 4, -1]$. Yasser will buy all of them, the total tastiness will be $7 + 4 - 1 = 10$. Adel can choose segments $[7], [4], [-1], [7, 4]$ or $[4, -1]$, their total tastinesses are $7, 4, -1, 11$ and $3$, respectively. Adel can choose segment with tastiness $11$, and as $10$ is not strictly greater than $11$, Yasser won't be happy :(

Find out if Yasser will be happy after visiting the shop.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

The first line of each test case contains $n$ ($2 \le n \le 10^5$).

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9$), where $a_i$ represents the tastiness of the $i$-th type of cupcake.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$.


-----Output-----

For each test case, print "YES", if the total tastiness of cupcakes Yasser buys will always be strictly greater than the total tastiness of cupcakes Adel buys regardless of Adel's choice. Otherwise, print "NO".


-----Example-----
Input
3
4
1 2 3 4
3
7 4 -1
3
5 -5 5

Output
YES
NO
NO



-----Note-----

In the first example, the total tastiness of any segment Adel can choose is less than the total tastiness of all cupcakes.

In the second example, Adel will choose the segment $[1, 2]$ with total tastiness $11$, which is not less than the total tastiness of all cupcakes, which is $10$.

In the third example, Adel can choose the segment $[3, 3]$ with total tastiness of $5$. Note that Yasser's cupcakes' total tastiness is also $5$, so in that case, the total tastiness of Yasser's cupcakes isn't strictly greater than the total tastiness of Adel's cupcakes.

Difficulty: EASY

Solutions:
from sys import maxsize
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	S = sum(A)
	mx = -maxsize - 1
	cur_mx = 0
	start = 0
	end = 0
	s = 0
	for i in range(n):
		cur_mx += A[i]
		if mx < cur_mx:
			mx = cur_mx
			start = s
			end = i
		if cur_mx <= 0:
			cur_mx = 0
			s = i + 1
	x = end - start + 1
	if S == mx:
		if x == n:
			print('YES')
		else:
			print('NO')
	elif S > mx:
		print('YES')
	else:
		print('NO')


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	mx1 = cur = -float('inf')
	for i in range(0, n - 1):
		cur = max(a[i], cur + a[i])
		mx1 = max(mx1, cur)
	mx2 = cur = -float('inf')
	for i in range(n - 1, 0, -1):
		cur = max(a[i], cur + a[i])
		mx2 = max(mx2, cur)
	if sm > max(mx1, mx2):
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	chsum = sum(arr)
	pref = [0] * n
	p = 0
	for i in range(n):
		p += arr[i]
		pref[i] = p
	pref = [0] + pref
	ch1 = max(pref[1:]) - min(pref[1:])
	ch2 = max(pref[:len(pref) - 1]) - min(pref[:len(pref) - 1])
	if ch1 >= chsum or ch2 >= chsum:
		ans = 'NO'
	else:
		ans = 'YES'
	out(ans)


INT_MAX = 10 ** 18 + 7
MOD = 10 ** 9 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]

def clac(A, n):
	ans1 = 0
	sum1 = 0
	for i in range(1, n):
		if sum1 + A[i] > 0:
			sum1 += A[i]
		else:
			sum1 = 0
		ans1 = max(ans1, sum1)
	sum2 = 0
	ans2 = 0
	for i in range(n - 1):
		if sum2 + A[i] > 0:
			sum2 += A[i]
		else:
			sum2 = 0
		ans2 = max(ans2, sum2)
	return max(ans2, ans1)
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	s = sum(A)
	if s > clac(A, n):
		print('YES')
	else:
		print('NO')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	y = sum(l)
	ma = curr = l[0]
	for i in range(1, n - 1):
		curr += l[i]
		ma = max(ma, curr)
		curr = max(curr, 0)
	curr = 0
	for i in range(1, n):
		curr += l[i]
		ma = max(ma, curr)
		curr = max(curr, 0)
	print('YES' if y > ma else 'NO')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
for _ in [0] * RI():
	lens = RI()
	arrs = RMI()
	answer = 'YES'
	rt_sum = 0
	for i in arrs:
		rt_sum += i
		if rt_sum <= 0:
			answer = 'NO'
			break
	if answer == 'YES':
		lt_sum = 0
		for i in arrs[::-1]:
			lt_sum += i
			if lt_sum <= 0:
				answer = 'NO'
				break
	print(answer)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	n = int(input())
	arr = array()
	s = sum(arr)
	curr = 0
	best1 = -INF
	best2 = -INF
	for i in range(n - 1):
		curr = max(arr[i], curr + arr[i])
		best1 = max(best1, curr)
	curr = 0
	for i in range(1, n):
		curr = max(arr[i], curr + arr[i])
		best2 = max(best2, curr)
	if max(best1, best2) >= s:
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(t):
	main()


def get_maxs(a):
	s = max(a[0], 0)
	maxs = s
	for i in range(1, len(a)):
		if a[i] < 0:
			maxs = max(maxs, s)
		s += a[i]
		if s < 0:
			s = 0
	return maxs
for _ in range(int(input())):
	(n, a) = (int(input()), list(map(int, input().split())))
	summ = sum(a)
	maxs = max(get_maxs(a[1:] + [-summ]), get_maxs(a[:-1] + [-summ]))
	print('YES' if summ > maxs else 'NO')


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	suff = 0
	pref = 0
	flag = 0
	for j in range(n - 1):
		suff += lst[j]
		pref += lst[n - 1 - j]
		if suff <= 0 or pref <= 0:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	j = sum(a)
	s = 0
	res = 'YES'
	for i in range(n - 1):
		s += a[i]
		if s < 0 or s >= j:
			res = 'NO'
			break
	if res == 'YES':
		s = 0
		for i in range(n - 1, 0, -1):
			s += a[i]
			if s < 0 or s >= j:
				res = 'NO'
				break
	print(res)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):

	def maxSubarray(A):
		cum = 0
		minCum = 0
		best = float('-inf')
		for (i, x) in enumerate(A):
			cum += x
			best = max(best, cum - minCum)
			minCum = min(minCum, cum)
		return best
	best = max(maxSubarray(A[1:]), maxSubarray(A[:-1]))
	if best < sum(A):
		return 'YES'
	else:
		return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


t = int(input())
for _ in range(t):
	p_sum = 0
	n_sum = 0
	count = 0
	n_count = 0
	n = int(input())
	l = input().split()
	l = [int(x) for x in l]
	i = 0
	max_sum = 0
	max_count = 0
	while i < n:
		if l[i] <= 0:
			n_sum += l[i]
			n_count += 1
		if l[i] > 0:
			if p_sum + n_sum > 0:
				p_sum += n_sum
				count += n_count
			else:
				p_sum = 0
				count = 0
			p_sum += l[i]
			count += 1
			if p_sum > max_sum and count != n:
				max_sum = p_sum
			elif count == n:
				if p_sum - l[0] > max_sum:
					max_sum = p_sum - l[0]
			n_sum = 0
			n_count = 0
		i += 1
	if max_sum >= sum(l):
		print('NO')
	else:
		print('YES')


t = int(input())

def f(a, it):
	s = 0
	for i in it:
		s += a[i]
		if s <= 0:
			return False
	return True

def check(a):
	n = len(a)
	return f(a, range(n - 1)) and f(a, reversed(range(1, n)))
for _ in range(t):
	_ = int(input())
	a = [int(x) for x in input().split()]
	if check(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	A = list(map(int, input().split()))
	(L, R) = (0, 0)
	ans = 'YES'
	for i in range(N - 1):
		L += A[i]
		R += A[-1 - i]
		if L <= 0 or R <= 0:
			ans = 'NO'
			break
	print(ans)


m = int(input())
for g in range(m):
	n = int(input())
	now = 0
	res = -99999999999
	was = False
	arr = list(map(int, input().split()))
	sm = sum(arr)
	for i in range(n):
		if arr[i] < 0:
			now += arr[i]
			if now < 0:
				now = 0
		else:
			now += arr[i]
		if now >= sm and i != n - 1:
			was = True
			break
	now = 0
	for i in range(n - 1, -1, -1):
		if arr[i] < 0:
			now += arr[i]
			if now < 0:
				now = 0
		else:
			now += arr[i]
		if now >= sm and i != 0:
			was = True
			break
	if was:
		print('NO')
	else:
		print('YES')


t = int(input())
for tt in range(t):
	n = int(input())
	a = [int(aa) for aa in input().split()]
	l = 0
	r = 0
	m = 0
	mr = 0
	temp = 0
	for i in range(len(a)):
		if temp + a[i] > 0:
			r = i
			temp += a[i]
			if temp > m:
				mr = i
				m = temp
		else:
			l = i + 1
			temp = 0
	s = sum(a)
	if s <= m and (l != 0 or mr != len(a) - 1):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	a = int(input())
	mas = list(map(int, input().split()))
	sim = sum(mas)
	dp = [0] * (a - 1)
	dp[0] = mas[0]
	for i in range(1, a - 1):
		dp[i] = max(dp[i - 1] + mas[i], mas[i])
	dp2 = [0] * (a - 1)
	dp2[0] = mas[1]
	for i in range(1, a - 1):
		dp2[i] = max(dp2[i - 1] + mas[i + 1], mas[i + 1])
	if sim <= max(max(dp), max(dp2)):
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	cmax = gmax = l[0]
	st = 0
	e = 0
	f = 0
	for i in range(1, n):
		if cmax + l[i] <= l[i]:
			st = i
		cmax = max(cmax + l[i], l[i])
		if gmax <= cmax:
			e = i
		gmax = max(gmax, cmax)
		if gmax >= s:
			if i == n - 1 and (st > 0 or e < n - 1):
				f = 1
				print('NO')
				break
			elif i < n - 1:
				f = 1
				print('NO')
				break
	if f == 0:
		print('YES')
	t -= 1


def verifyAnswer(max, total, positive, arrayLen, index, maxindex):
	if total > max:
		print('YES')
	elif positive == arrayLen:
		print('YES')
	elif total == max:
		if index == arrayLen:
			if maxindex + 1 < arrayLen:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')
	else:
		print('NO')

def verifyArray():
	max = -10000000000
	res = 0
	total = 0
	arrayLen = int(input())
	positive = 0
	maxindex = -1
	index = 0
	arr = list(map(int, input().split()))
	for i in range(int(arrayLen)):
		total += arr[i]
		if arr[i] + res <= 0:
			res = 0
		elif arr[i] + res > 0:
			if arr[i] > 0:
				positive += 1
			res += arr[i]
			index += 1
		if res > max:
			max = res
			maxindex = i
	verifyAnswer(max, total, positive, arrayLen, index, maxindex)

def main():
	for i in range(int(input())):
		verifyArray()
main()


import sys

def answer(n, a):
	Yasser = sum(a)
	lptr = 0
	if a[0] >= Yasser:
		return 'NO'
	summ = [a[0]]
	for i in range(1, n):
		if a[i] >= a[i] + summ[i - 1]:
			lptr = i
		summ.append(max(a[i], a[i] + summ[i - 1]))
		if summ[i] >= Yasser and (lptr > 0 or i < n - 1):
			return 'NO'
	return 'YES'

def main():
	t = int(input())
	while t:
		n = int(sys.stdin.readline())
		a = [int(i) for i in sys.stdin.readline().split()]
		print(answer(n, a))
		t -= 1
	return
main()


t = int(input())
for r in range(t):
	n = int(input())
	m = input().split()
	a = 0
	b = 0
	for h in range(n - 1):
		a = a + int(m[h])
		b = b + int(m[n - h - 1])
		if a < 1 or b < 1:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
l2 = []
for i in range(t):
	n = int(input())
	c = 0
	c2 = 0
	flag = 0
	k1 = 0
	l1 = [int(a) for a in input().split()]
	if n != 1:
		for k in range(n):
			c2 += l1[k]
		for k in range(n):
			c += l1[k]
			k1 += 1
			if c >= c2:
				if k1 != n:
					flag = 1
					break
			if c <= 0:
				c = 0
				k1 = 0
	else:
		l2.append('NO')
	if flag == 1:
		l2.append('NO')
	else:
		l2.append('YES')
for i in range(t):
	print(l2[i])


t = int(input())
dp = [int()] * 100000
while t > 0:
	n = int(input())
	arr = [int(x) for x in input().split()]
	total = sum(arr)
	(s, mx, l, r) = [0, 0, 0, 0]
	for i in range(0, n):
		if s + arr[i] <= 0:
			s = 0
			l = i + 1
		else:
			s += arr[i]
		if s > mx:
			mx = s
			r = i
	if mx >= total and (l != 0 or r != n - 1):
		print('NO')
	else:
		print('YES')
	t -= 1


from functools import reduce

def is_tastiness_greater_or_equal_than(cupcakes_tastiness, tastiness_to_compare):
	total_tastiness = 0
	for tastiness in cupcakes_tastiness:
		total_tastiness += tastiness
		if total_tastiness >= tastiness_to_compare:
			return True
	return False

def will_yasser_be_happy(cupcakes_tastiness):
	yasser_tastiness = reduce(lambda x, y: x + y, cupcakes_tastiness)
	cupcakes_tastiness_without_last = cupcakes_tastiness[:-1]
	if is_tastiness_greater_or_equal_than(cupcakes_tastiness_without_last, yasser_tastiness):
		return 'NO'
	cupcakes_tastiness_reverse = cupcakes_tastiness[::-1]
	cupcakes_tastiness_reverse_without_last = cupcakes_tastiness_reverse[:-1]
	if is_tastiness_greater_or_equal_than(cupcakes_tastiness_reverse_without_last, yasser_tastiness):
		return 'NO'
	return 'YES'
test_cases = int(input())
responses = []
for i in range(0, test_cases):
	cupcakes = int(input())
	cupcakes_tastiness = [int(i) for i in input().split()]
	responses.append(will_yasser_be_happy(cupcakes_tastiness))
for response in responses:
	print(response)


n = int(input())
for t in range(n):
	m = int(input())
	a = list(map(int, input().split()))
	ans1 = sum(a)
	ans2 = 0
	dlina = 0
	maxim = 0
	for i in range(m):
		if dlina != m - 1:
			ans2 += a[i]
			if ans2 > 0:
				dlina += 1
			else:
				ans2 = 0
				dlina = 0
			maxim = max(maxim, ans2)
		else:
			maxim = max(maxim, sum(a[0:m - 1]), sum(a[1:]))
			break
	if maxim >= ans1:
		print('NO')
	else:
		print('YES')


k = int(input())
for _ in range(k):
	n = int(input())
	cup = [int(x) for x in input().split()]
	c1 = cup[1:]
	c2 = cup[:len(cup) - 1]
	yasser = sum(cup)
	maxC = 0
	cur = 0
	for i in c1:
		cur += i
		if cur < 0:
			cur = 0
		maxC = max(maxC, cur)
	maxC2 = 0
	cur = 0
	for i in c2:
		cur += i
		if cur < 0:
			cur = 0
		maxC2 = max(maxC2, cur)
	maxC = max(maxC, maxC2)
	if yasser > maxC:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = map(int, input().split())
	s = list(s)
	q = sum(s)
	c = True
	res = 0
	for j in range(n - 1):
		res += s[j]
		if res >= q:
			c = False
			break
	if c == False:
		print('NO')
	else:
		s = reversed(s)
		s = list(s)
		res = 0
		for j in range(n - 1):
			res += s[j]
			if res >= q:
				c = False
				break
		if c == False:
			print('NO')
		else:
			print('YES')


def MSAS(a):
	(s, cursum) = (-10 ** 14, -10 ** 14)
	for num in a:
		cursum = max(cursum + num, num)
		s = max(s, cursum)
	return s
for test_case in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(b, c) = (list(a), list(a))
	b.pop(0)
	c.pop()
	(s1, s2, s3) = (sum(a), MSAS(b), MSAS(c))
	if s1 > s2 and s1 > s3:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	a = int(input())
	b = list(map(int, input().split()))
	j = 0
	l = 0
	t = []
	for z in range(a - 1):
		j = j + b[z]
		if j < 0:
			j = 0
		if l < j:
			l = j
	t.append(l)
	j = 0
	l = 0
	for z in range(1, a):
		j = j + b[z]
		if j < 0:
			j = 0
		if l < j:
			l = j
	t.append(l)
	if max(t) >= sum(b):
		print('NO')
	else:
		print('YES')


import sys

def solve(a, start, end):
	max_sum = -sys.maxsize - 1
	max_till_here = 0
	for i in range(start, end):
		max_till_here += a[i]
		if a[i] > max_till_here:
			max_till_here = a[i]
		if max_till_here > max_sum:
			max_sum = max_till_here
	return max_sum
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s > max(solve(a, 0, n - 1), solve(a, 1, n)):
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def kadane(b):
	gans = -float('inf')
	cs = 0
	for i in b:
		cs += i
		gans = max(gans, cs)
		if cs < 0:
			cs = 0
	return gans
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	sm = sum(a)
	v = a.pop()
	if kadane(a) >= sm:
		print('NO')
		continue
	a.append(v)
	a.pop(0)
	if kadane(a) >= sm:
		print('NO')
		continue
	print('YES')


def sub(arr):
	n = len(arr)
	m = cur = arr[0]
	for i in range(1, n):
		cur = max(arr[i], arr[i] + cur)
		m = max(m, cur)
	return m
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	x = sub(a[1:])
	y = sub(a[:-1])
	if max(x, y) < s:
		print('YES')
	else:
		print('NO')


for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	m = 0
	x = 0
	c = 0
	c1 = 0
	m1 = 0
	m2 = 0
	for i in range(n):
		x += a[i]
		if x <= 0:
			x = 0
			c = 1
		if m < x:
			m = x
		if a[i] > 0:
			c1 += 1
	x = 0
	for i in range(n - 1):
		x += a[i]
		if x <= 0:
			x = 0
		if m1 < x:
			m1 = x
	x = 0
	for i in range(1, n):
		x += a[i]
		if x <= 0:
			x = 0
		if m2 < x:
			m2 = x
	if m < s:
		print('YES')
	elif m == s:
		if c == 1 or m1 == m or m2 == m:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


from sys import maxsize

def maxSubArraySum(a, size):
	max_so_far = -maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here <= 0:
			max_ending_here = 0
			s = i + 1
	if end - start != n - 1:
		return max_so_far
	else:
		return -9999999999999999999
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	nums = arr
	s = sum(arr)
	if s > maxSubArraySum(arr, n):
		print('YES')
	else:
		print('NO')


def function(l, n):
	sum1 = 0
	sum2 = 0
	for i in range(0, n):
		sum1 += l[i]
		sum2 += l[n - 1 - i]
		if sum1 <= 0:
			return 0
		if sum2 <= 0:
			return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if function(l, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = sum(l)
	p = 0
	r = True
	for i in range(n - 1):
		p = p + l[i]
		if p <= 0 or p >= a:
			r = False
			print('NO')
			break
	if r:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	track = a[0]
	s = sum(a)
	flag = 0
	for i in range(1, n - 1):
		if 0 < track < s:
			pass
		else:
			flag = 1
		track += a[i]
	if flag == 0 and 0 < track < s:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	x = 0
	ans = []
	for t in range(1, n):
		if x + l[t] >= 0:
			x += l[t]
			ans.append(x)
		else:
			x = 0
	x = 0
	for t in range(n - 1):
		if x + l[t] >= 0:
			x += l[t]
			ans.append(x)
		else:
			x = 0
	if len(ans) > 0:
		x = max(ans)
		print('YES' if x < s else 'NO')
	else:
		print('NO')


t = int(input())

def solve(s):
	dp = [0] * len(s)
	dp[0] = s[0]
	for i in range(1, len(s)):
		dp[i] = max(s[i], dp[i - 1] + s[i])
	return max(dp)
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	s1 = a[1:]
	s2 = a[:-1]
	p = max(solve(s1), solve(s2))
	if y > p:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	prev = 0
	psum = [[0, -1] for i in range(n)]
	if arr[0] > 0:
		psum[0][1] = 0
		pi = 0
	for i in range(n):
		if prev <= 0:
			pi = i
		prev = prev + arr[i]
		if prev < 0:
			prev = 0
		psum[i][0] = prev
		psum[i][1] = pi
	tsum = sum(arr)
	boo = False
	for i in range(n):
		if psum[i][0] >= tsum:
			if psum[i][1] == 0 and i == n - 1:
				boo = boo or False
			else:
				boo = boo or True
	if boo:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	sum = 0
	flag = 0
	for i in range(len(ls)):
		sum += ls[i]
		if sum <= 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		s = 0
		l = ls[::-1]
		for i in range(len(l)):
			s += l[i]
			if s <= 0:
				flag = 1
				break
		if flag == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	x = int(input())
	(*li,) = map(int, input().split())
	ans1 = sum(li)
	(cnt, ans) = (0, 0)
	if ans1 <= sum(li[:-1]) or ans1 <= sum(li[1:]):
		print('NO')
		continue
	flag = False
	i = 0
	while i < x - 1 or (i < x and flag):
		cnt += li[i]
		ans = max(ans, cnt)
		if ans >= ans1:
			print('NO')
			break
		if cnt <= 0:
			cnt = 0
			flag = True
		i += 1
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sum = 0
	for i in a:
		sum += i
	c1 = 0
	s = 0
	r = 0
	for i in range(n - 1):
		c1 = max(c1 + a[i], a[i])
		s = max(c1, s)
	c2 = 0
	for i in range(1, n):
		c2 = max(c2 + a[i], a[i])
		r = max(c2, s)
	res = max(s, r)
	if res >= sum:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	start = 0
	end = 0
	tempsum = a[0]
	finalsum = a[0]
	fl = 0
	fr = 0
	for i in range(1, n):
		if a[i] > tempsum + a[i]:
			start = i
			end = i
			tempsum = a[i]
		else:
			end = i
			tempsum = tempsum + a[i]
		if tempsum > finalsum:
			finalsum = tempsum
			fl = start
			fr = end
	if finalsum > sum(a):
		print('NO')
	else:
		count = 0
		tempsum = a[0]
		finalsum = a[0]
		for i in range(1, n):
			tempsum = max(tempsum + a[i], a[i])
			if tempsum == 0:
				count += 1
				break
		a = a[::-1]
		tempsum = a[0]
		finalsum = a[0]
		for i in range(1, n):
			tempsum = max(tempsum + a[i], a[i])
			if tempsum == 0:
				count += 1
				break
		if count >= 1:
			print('NO')
		else:
			print('YES')


def F(a, lst):
	summ = sum(lst)
	cur = 0
	for i in range(a - 1):
		cur += lst[i]
		if cur <= 0 or summ - cur <= 0:
			print('NO')
			return 0
	print('YES')
n = int(input())
for i in range(n):
	a = int(input())
	lst = list(map(int, input().split()))
	F(a, lst)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	f = True
	for x in a:
		s += x
		if s <= 0:
			f = False
	s = 0
	for i in range(len(a) - 1, -1, -1):
		s += a[i]
		if s <= 0:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	t = sum(a)
	p = []
	s = 0
	m = 0
	su = 0
	z = 0
	for i in range(n):
		s += a[i]
		if i == n - 1:
			if s - m >= t:
				if z == 1:
					su = 1
			break
		if s <= m:
			m = s
			z = 1
		if s - m >= t:
			su = 1
			break
	if su == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	m = 0
	ab = a[1:]
	ac = a[:-1]
	dp = [0] * len(ab)
	dp[0] = ab[0]
	for i in range(1, len(ab)):
		dp[i] = max(ab[i], ab[i] + dp[i - 1])
	m = max(dp)
	dp = [0] * len(ac)
	dp[0] = ac[0]
	for i in range(1, len(ac)):
		dp[i] = max(ac[i], ac[i] + dp[i - 1])
	m = max(m, max(dp))
	if m >= y:
		print('NO')
	else:
		print('YES')


def has_negative_prefix(a):
	sum = 0
	for e in a:
		sum += e
		if sum <= 0:
			return True
	return False
t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	if has_negative_prefix(a):
		print('NO')
	else:
		a.reverse()
		if has_negative_prefix(a):
			print('NO')
		else:
			print('YES')
	t = t - 1


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	x = 0
	y = 0
	z = 0
	for j in b:
		x = x + j
		if x <= 0:
			y = y + 1
	for k in range(a):
		z = z + b[a - k - 1]
		if z <= 0:
			y = y + 1
	if y >= 1:
		print('NO')
	else:
		print('YES')


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	a = I()
	yass = sum(a)
	ans = 'YES'
	cur = 0
	for i in range(n - 1):
		cur += a[i]
		if cur >= yass:
			ans = 'NO'
			break
		cur = max(cur, 0)
	cur = 0
	for i in range(1, n):
		cur += a[i]
		if cur >= yass:
			ans = 'NO'
			break
		cur = max(cur, 0)
	print(ans)


cases = int(input())
for _ in range(cases):
	input()
	arr = [int(a) for a in input().strip().split()]
	cm = 0
	tm = 0
	sm = 0
	st = 0
	ed = 0
	success_tup = (0, 0)
	for (i, a) in enumerate(arr):
		sm += a
		tm += a
		if tm > 0:
			if tm > cm:
				cm = tm
				ed = i
				success_tup = (st, ed)
		else:
			tm = 0
			st = i + 1
			ed = i + 1
	if success_tup == (0, len(arr) - 1):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ansl = arr[0]
	curl = arr[0]
	ansr = arr[n - 1]
	curr = arr[n - 1]
	tot = arr[0]
	for i in range(1, n - 1):
		curl = max(curl + arr[i], arr[i])
		ansl = max(ansl, curl)
		tot += arr[i]
		curr = max(arr[n - i - 1], curr + arr[n - i - 1])
		ansr = max(curr, ansr)
	tot += arr[n - 1]
	if max(ansl, ansr) >= tot:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	ans = -float('inf') - 1
	this = 0
	for i in array[:-1]:
		this = this + i
		if this < 0:
			this = 0
		ans = max(ans, this)
	this = 0
	for i in array[1:]:
		this = this + i
		if this < 0:
			this = 0
		ans = max(ans, this)
	sumo = sum(array)
	if sumo > ans:
		print('YES')
	else:
		print('NO')


import sys

def main():
	T = int(sys.stdin.readline())
	for _ in range(T):
		N = int(sys.stdin.readline())
		tastes = [int(x) for x in sys.stdin.readline().split()]
		result = True
		yasser_choice = sum(tastes)
		adel_choice = 0
		for i in range(0, N - 1):
			adel_choice += tastes[i]
			if adel_choice >= yasser_choice:
				result = False
				break
			if adel_choice < 0:
				adel_choice = 0
		adel_choice = 0
		for i in range(1, N):
			adel_choice += tastes[i]
			if adel_choice >= yasser_choice:
				result = False
				break
			if adel_choice < 0:
				adel_choice = 0
		sys.stdout.write(f"{('YES' if result is True else 'NO')}\n")
main()


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().strip().split()))
	yas = sum(a)
	if a[0] >= yas:
		print('NO')
		continue
	flag = 1
	msf = a[0]
	ans = a[0]
	count = 1
	for num in a[1:]:
		if num >= msf + num:
			count = 0
		else:
			count += 1
		msf = max(msf + num, num)
		if msf >= ans:
			ans = msf
		if ans >= yas and count != n:
			print('NO')
			flag = 0
			break
	if flag:
		print('YES')


def kadane(arr):
	n = len(arr)
	max_curr = arr[0]
	max_global = arr[0]
	for i in range(1, n):
		max_curr = max(arr[i], max_curr + arr[i])
		max_global = max(max_global, max_curr)
	return max_global
t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	tsum = sum(arr)
	max_global_1 = kadane(arr[1:])
	max_global_2 = kadane(arr[0:n - 1])
	ans = max(max_global_1, max_global_2)
	if tsum > ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	N = int(input())
	A = [int(x) for x in input().split()]
	rui = 0
	for i in range(N):
		rui += A[i]
		if rui <= 0:
			print('NO')
			break
	else:
		rui = 0
		for i in range(N - 1, -1, -1):
			rui += A[i]
			if rui <= 0:
				print('NO')
				break
		else:
			print('YES')


def solve(A):
	s = sum(A)
	l = 0
	r = 0
	curr = 0
	gmax = float('-INF')
	for i in range(len(A)):
		if curr + A[i] > A[i]:
			curr += A[i]
		else:
			l = i
			curr = A[i]
		if curr > gmax:
			r = i
		gmax = max(gmax, curr)
	if s > gmax:
		return 'YES'
	if s == gmax:
		if l == 0 and r == len(A) - 1:
			return 'YES'
		else:
			return 'NO'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	print(solve(a))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	fa = a[0]
	la = a[n - 1]
	s = sum(a)
	ans = 'YES'
	su = 0
	for i in range(n - 1):
		su += a[i]
		if su <= 0:
			ans = 'NO'
	su = 0
	for i in range(n - 1, 0, -1):
		su += a[i]
		if su <= 0:
			ans = 'NO'
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	suma = sum(a)
	ms = -999999999
	cs = 0
	su = 0
	for j in range(n - 1):
		su += a[j]
		if a[j] > 0:
			cs += a[j]
		if su > ms:
			ms = su
		if su < 0:
			su = 0
	if cs == 0:
		cs = max(a)
	ms1 = -999999999
	cs1 = 0
	su1 = 0
	for j in range(1, n):
		su1 += a[j]
		if a[j] > 0:
			cs1 += a[j]
		if su1 > ms1:
			ms1 = su1
		if su1 < 0:
			su1 = 0
	if cs1 == 0:
		cs1 = max(a)
	c = max(cs, cs1)
	s = max(ms, ms1)
	if suma > s:
		print('YES')
	else:
		print('NO')


def intinputlist():
	l = [int(x) for x in input().split()]
	return l

def printlist(l):
	print(*l)

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
t = int(input())
while t:
	n = int(input())
	a = intinputlist()
	psum = 0
	ind = 1
	for i in range(n):
		psum += a[i]
		if psum <= 0:
			ind = 0
			break
	ssum = 0
	for i in range(n):
		ssum += a[n - 1 - i]
		if ssum <= 0:
			ind = 0
			break
	if ind == 0:
		print('NO')
	else:
		print('YES')
	t -= 1


def solution(n, pir):
	s = 0
	su = sum(pir)
	for i in range(n - 1):
		s += pir[i]
		ss = su - s
		if s <= 0 or ss <= 0:
			print('NO')
			return
	print('YES')
t = int(input())
for i in range(t):
	n = int(input())
	pir = list(map(int, input().split()))
	solution(n, pir)


def solve(a):
	m = float('-inf')
	m1 = 0
	for i in range(len(a)):
		m1 = m1 + a[i]
		if m < m1:
			m = m1
		if m1 < 0:
			m1 = 0
	return m
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) > max(solve(a[:-1]), solve(a[1:])):
		print('YES')
	else:
		print('NO')


def mssl(l):
	best = cur = 0
	for i in range(len(l) - 1):
		cur = max(cur + l[i], 0)
		best = max(best, cur)
	cur = 0
	for i in range(len(l) - 1, 0, -1):
		cur = max(cur + l[i], 0)
		best = max(best, cur)
	return best
t = int(input())
for ti in range(t):
	n = int(input())
	s = input()
	a = list(map(lambda x: int(x), s.split()))
	asms = mssl(a)
	s1 = sum(a)
	if asms >= s1:
		print('NO')
	else:
		print('YES')


for _ in ' ' * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	mx = min(a)
	b = 0
	f = 0
	for i in range(1, n):
		b += a[i]
		if mx < b:
			mx = b
		if b < 0:
			b = 0
	b = 0
	for i in range(0, n - 1):
		b += a[i]
		if mx < b:
			mx = b
		if b < 0:
			b = 0
	if sm > mx:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [a[0]]
	flag = 0
	for i in range(1, n):
		if a[i] > a[i] + dp[-1] or a[i] + dp[-1] == 0:
			flag = 1
			dp.append(a[i])
		else:
			dp.append(a[i] + dp[-1])
	if flag == 1:
		if max(dp) >= sum(a):
			print('NO')
		else:
			print('YES')
	elif max(dp) == dp[-1]:
		if max(dp[:-1]) >= sum(a):
			print('NO')
		else:
			print('YES')
	elif max(dp) >= sum(a):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	best = sum(a)
	max_so_far = 0
	max_ending_here = 0
	from_start = True
	for i in range(n):
		max_ending_here += a[i]
		if max_ending_here <= 0:
			max_ending_here = 0
			from_start = False
		if max_so_far < max_ending_here and (not (from_start and i == n - 1)):
			max_so_far = max_ending_here
	if max_so_far >= best:
		print('NO')
	else:
		print('YES')


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	n = int(sys.stdin.readline().rstrip())
	s = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	ls = len(s)
	a = 0
	b = 0
	for i in range(ls):
		a += s[i]
		b += s[-i - 1]
		if a <= 0 or b <= 0:
			print('NO')
			break
	else:
		print('YES')


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	yas = sum(arr)
	x = maxSubArraySum(arr[:n - 1], n - 1)
	y = maxSubArraySum(arr[1:], n - 1)
	adel = max(x, y)
	if yas > adel:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	y = sum(l)
	total = 0
	happy = True
	for i in range(n - 1):
		total += l[i]
		if total >= y:
			print('NO')
			happy = False
			break
	if happy:
		max_ending_here = 0
		max_so_far = -100000
		for i in range(1, n):
			max_ending_here += l[i]
			max_so_far = max(max_so_far, max_ending_here)
			max_ending_here = max(0, max_ending_here)
		if max_so_far >= y:
			print('NO')
		else:
			print('YES')


def maxSubArraySum(a, size):
	max_so_far = -99999999999999999999999 - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for fghj in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	maxsum = maxSubArraySum(a, n)
	ax = maxSubArraySum(a[1:], n - 1)
	ay = maxSubArraySum(a[:n], n - 1)
	if ax < maxsum and ay < maxsum:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(v) for v in input().split()]
	p = [a[0]]
	f = 0
	m = a[0]
	s = sum(a)
	for j in range(1, n - 1):
		p.append(max(p[-1] + a[j], a[j]))
		m = max(p[-1], m)
	p = [a[1]]
	v = m
	m = a[1]
	for j in range(2, n):
		p.append(max(p[-1] + a[j], a[j]))
		m = max(p[-1], m)
	if v >= s or m >= s:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	T = list(map(int, input().split()))
	a = sum(T)
	ans = True
	i = s = 0
	while i < N - 1:
		s += T[i]
		if s >= a:
			ans = False
		if s < 0:
			s = 0
		i += 1
	i = 1
	s = 0
	while i < N:
		s += T[i]
		if s >= a:
			ans = False
		if s < 0:
			s = 0
		i += 1
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	prev = 0
	res = 0
	flag = True
	for i in range(n):
		el = a[i]
		if i == 0:
			prev = el
			res = el
		else:
			prev += el
			if i == n - 1 and flag:
				res = max(res, prev - min(a[0], a[n - 1]))
			else:
				res = max(res, prev - m)
				if m >= prev:
					m = prev
					flag = False
	if prev > res:
		print('YES')
	else:
		print('NO')


from itertools import *
A = accumulate
I = input
for _ in [0] * int(I()):
	I()
	a = (*map(int, I().split()),)
	(b, c) = ([0, *A(A(x), min)] for x in (a, a[::-1]))
	print('YNEOS'[any((x + y <= 0 for (x, y) in zip(b, c[-2::-1])))::2])


t = int(input())
l = []
for i in range(t):
	n = int(input())
	a = input().split()
	ne = 0
	np = 0
	for i in range(n):
		a[i] = int(a[i])
		if a[i] < 0:
			ne = 1
		if a[i] > 0:
			np = 1
	if ne == 0 and np == 0:
		l.append('NO')
		continue
	if ne == 0:
		l.append('YES')
		continue
	soy = 0
	soa = 0
	for i in range(n):
		soy = soy + a[i]
	f = 0
	maxiend = 0
	maxifar = -999999
	p = 0
	q = 0
	u = 0
	for i in range(n):
		maxiend = maxiend + a[i]
		if maxiend > 0:
			q = 1
		if maxifar < maxiend:
			maxifar = maxiend
		if maxiend <= 0:
			maxiend = 0
			p = 1
		if maxifar >= soy:
			f = 1
			u = i
			break
	if f == 1:
		if maxifar > soy:
			l.append('NO')
			continue
		if maxifar == soy and q == 1 and (p == 1) or u != n - 1:
			l.append('NO')
			continue
		else:
			l.append('YES')
			continue
	if f == 0:
		l.append('YES')
for i in l:
	print(i)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().strip().split()]
	b = [0] * n
	c = [0] * n
	pre = 0
	maxn = max(0, a[0])
	maxn2 = 0
	s = 0
	Yasser = sum(a)
	if n == 2:
		if min(a) > 0:
			print('YES')
		else:
			print('NO')
		continue
	pre = max(0, a[0])
	pre2 = 0
	b[0] = pre
	for (i, aa) in enumerate(a[1:-1], start=1):
		temp = max(0, pre + aa)
		temp2 = max(0, pre2 + aa)
		b[i] = temp
		c[i] = temp2
		pre = temp
		pre2 = temp2
		maxn = max(maxn, pre)
		maxn2 = max(maxn2, pre2)
	if a[-1] > 0:
		c[-1] = c[-2] + a[-1]
		maxn2 = max(maxn2, c[-1])
	Adel = max(maxn, maxn2)
	if Yasser > Adel:
		print('YES')
	else:
		print('NO')


import sys, os.path
import math
from collections import defaultdict, deque
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input1()))

def main():
	(t,) = I()
	for t1 in range(t):
		(n,) = I()
		a = I()
		dp = [0] * (n - 1)
		min1 = a[0]
		dp[0] = a[0]
		prefix = a[0]
		for i in range(1, n - 1):
			prefix += a[i]
			dp[i] = max(dp[i - 1] + a[i], prefix - min1, a[i])
			min1 = min(min1, dp[i])
		sum1 = sum(a)
		a = a[1:]
		dp1 = [0] * (n - 1)
		min1 = a[0]
		dp1[0] = a[0]
		prefix = a[0]
		for i in range(1, len(a)):
			prefix += a[i]
			dp1[i] = max(dp1[i - 1] + a[i], prefix - min1, a[i])
			min1 = min(min1, dp1[i])
		if sum1 > max(dp) and sum1 > max(dp1):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	a = []
	l1 = 0
	r = 0
	f = 0
	for i in range(len(l)):
		l1 += l[i]
		r += l[n - i - 1]
		if l1 <= 0 or r <= 0:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	fl = 0
	pre = [arr[0]]
	for i in range(1, len(arr)):
		pre.append(pre[i - 1] + arr[i])
	suff = [arr[-1]]
	for i in range(len(arr) - 2, -1, -1):
		suff.append(suff[len(arr) - i - 2] + arr[i])
	for i in range(len(arr)):
		if suff[i] <= 0 or pre[i] <= 0:
			fl = 1
			break
	if fl == 0:
		print('YES')
	else:
		print('NO')


import math
num_testcase = int(input())
for testcase in range(0, num_testcase):
	n = int(input())
	arr = input()
	arr = arr.split(' ')
	sum = 0
	for i in range(0, len(arr)):
		arr[i] = int(arr[i])
		sum += arr[i]
	dp = [0]
	for i in range(0, len(arr)):
		dp.append(dp[i] + arr[i])
	max_neg = -math.inf
	max_neg_index = 0
	funny = True
	for i in range(1, len(dp)):
		if dp[i] <= 0 and dp[i] > max_neg:
			max_neg = dp[i]
			max_neg_index = i
	if max_neg == -math.inf:
		for i in range(0, len(dp)):
			if dp[i] >= sum and i < n:
				funny = False
	else:
		max = -math.inf
		for i in range(max_neg_index, len(dp)):
			if dp[i] > max:
				max = dp[i]
		if max - max_neg >= sum:
			funny = False
	if funny == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	q = 'YES'
	su = 0
	for i in range(n - 1):
		su += l[i]
		if su <= 0:
			q = 'NO'
	su = 0
	for i in range(n - 1, 0, -1):
		su += l[i]
		if su <= 0:
			q = 'NO'
	print(q)


for _ in range(int(input())):
	n = int(input())
	pie = list(map(int, input().split()))
	min_pr = [0] * n
	min_sf = [0] * n
	min_pr[0] = sm = pie[0]
	for i in range(1, n):
		sm += pie[i]
		min_pr[i] = min(sm, min_pr[i - 1])
	min_sf[-1] = sm = pie[-1]
	for i in range(n - 2, -1, -1):
		sm += pie[i]
		min_sf[i] = min(sm, min_sf[i + 1])
	allsum = sum(pie)
	mx = min_sf[0]
	for piv in range(1, n):
		mx = min(mx, min_pr[piv - 1] + min_sf[piv])
	mx = min(mx, min_pr[-1])
	print('NO' if mx <= 0 else 'YES')


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	s = sum(lst)
	m = 0
	c = 0
	for i in range(1, n):
		c += lst[i]
		if c > m:
			m = c
		elif c < 0:
			c = 0
	c = 0
	for i in range(n - 1):
		c += lst[i]
		if c > m:
			m = c
		elif c < 0:
			c = 0
	if s > m:
		print('YES')
	else:
		print('NO')


def mSum(a, n):
	msf = a[0]
	cm = a[0]
	for i in range(1, n):
		cm = max(a[i], cm + a[i])
		msf = max(msf, cm)
	return msf
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	yasser = sum(a)
	flag = 0
	if len(a) == 1:
		print('NO')
		continue
	ans = mSum(a[:n - 1], n - 1)
	ans1 = mSum(a[1:], n - 1)
	ans = max(ans, ans1)
	if yasser == 0 and ans == 0:
		print('NO')
		continue
	elif ans >= yasser:
		print('NO')
	else:
		print('YES')


def cakes(n, a):
	yaseer = sum(a)
	maxi = -99999999
	temp = maxi
	for i in range(1, n):
		temp = max(temp + a[i], a[i])
		maxi = max(maxi, temp)
	maxi2 = -99999999
	temp = maxi2
	for i in range(n - 1):
		temp = max(temp + a[i], a[i])
		maxi2 = max(maxi2, temp)
	if max(maxi, maxi2) < yaseer:
		return 'YES'
	return 'NO'
test = int(input())
for i in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	print(cakes(n, a))


tests = int(input())
for te in range(tests):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = 0
	flag = 1
	for i in range(n):
		ans += arr[i]
		if ans <= 0:
			flag = 0
			break
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += arr[i]
		if ans <= 0:
			flag = 0
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	acc = list(accumulate(A))
	accrev = list(accumulate(A[::-1]))
	if min(acc) <= 0 or min(accrev) <= 0:
		NO()
	else:
		YES()


import math

def get_max(l, ll, rr):
	s = [0]
	maxx = 0
	min_pos = 0
	max_pos = 0
	for i in range(ll, rr):
		s.append(l[i] + s[-1])
	for i in range(len(s)):
		if s[i] < s[min_pos]:
			min_pos = i
		elif s[i] - s[min_pos] > maxx:
			maxx = s[i] - s[min_pos]
	return maxx
t = int(input())
for i in range(t):
	input()
	l = list(map(int, input().split(' ')))
	s = [0]
	maxx = get_max(l, 0, len(l))
	maxx2 = get_max(l, 1, len(l))
	maxx3 = get_max(l, 0, len(l) - 1)
	if maxx > maxx2 and maxx > maxx3:
		print('YES')
	else:
		print('NO')


def MaxSubArraySum(a, size):
	(max_current, max_global, max_current_two, max_global_two) = (0, 0, 0, 0)
	for i in range(size - 1):
		max_current = max(a[i], max_current + a[i])
		if max_current > max_global:
			max_global = max_current
	for i in range(1, size):
		max_current_two = max(a[i], max_current_two + a[i])
		if max_current_two > max_global_two:
			max_global_two = max_current_two
	return max(max_global, max_global_two)
for i in range(int(input())):
	size = int(input())
	cakes = [int(i) for i in input().split()]
	if sum(cakes) > MaxSubArraySum(cakes, size):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	t = sum(x)
	ans = 'YES'
	a = 0
	b = 0
	for j in range(n - 1):
		a += x[j]
		b += x[-j - 1]
		if a >= t:
			ans = 'NO'
			break
		if b >= t:
			ans = 'NO'
			break
	print(ans)


tests = int(input())
for _ in range(tests):
	n = int(input())
	pos = 0
	neg = 0
	t = 0
	arr = list(map(int, input().split()))
	j = n - 1
	t1 = 0
	for i in range(n):
		if t + arr[i] <= 0:
			neg = 1
			break
		t += arr[i]
		if t1 + arr[j] <= 0:
			neg = 1
			break
		t1 += arr[j]
		j -= 1
	if neg == 1:
		print('NO')
	else:
		print('YES')


n = int(input())

def judge(a):
	cur_max = last_max = a[0]
	result_0 = a[0]
	for i in range(1, t - 1):
		if last_max + a[i] < a[i]:
			cur_max = a[i]
		else:
			cur_max = last_max + a[i]
		if result_0 < cur_max:
			result_0 = cur_max
		last_max = cur_max
	cur_max_1 = last_max_1 = a[1]
	result_1 = a[1]
	for i in range(2, t):
		if last_max_1 + a[i] < a[i]:
			cur_max_1 = a[i]
		else:
			cur_max_1 = last_max_1 + a[i]
		if result_1 < cur_max_1:
			result_1 = cur_max_1
		last_max_1 = cur_max_1
	return max(result_0, result_1)
for i in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	b = sum(a)
	result = judge(a)
	if b > result:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	flag = 0
	s1 = 0
	for i in a:
		s1 += i
		if s1 <= 0:
			flag = 1
			break
	if flag == 0:
		s1 = 0
		for i in range(n - 1, -1, -1):
			s1 += a[i]
			if s1 <= 0:
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


from sys import setrecursionlimit
setrecursionlimit(1000000)
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	tmp = 0
	try:
		for i in range(n - 1):
			tmp += arr[i]
			if tmp <= 0 or tmp >= s:
				raise ValueError
	except:
		print('NO')
	else:
		print('YES')


def eatit(n, a):
	ysum = sum(a)
	i = 1
	asum = a[0]
	if asum >= ysum:
		return 'NO'
	while i < n - 1:
		asum = asum + a[i]
		if asum >= ysum:
			return 'NO'
		i = i + 1
	asum = a[-1]
	if asum >= ysum:
		return 'NO'
	i = n - 2
	while n >= 2 and i > 0:
		asum = asum + a[i]
		if asum >= ysum:
			return 'NO'
		i = i - 1
	return 'YES'
t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	print(eatit(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [0] * n
	dp[0] = a[0]
	ap = [0] * n
	for i in range(1, n):
		if dp[i - 1] + a[i] > a[i]:
			dp[i] = dp[i - 1] + a[i]
			ap[i] = ap[i - 1]
		else:
			dp[i] = a[i]
			ap[i] = i
	m = max(dp)
	i = dp.index(m)
	if m < sum(a):
		print('YES')
	elif m == sum(a):
		if i == n - 1 and ap[i] == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	total = sum(arr)
	s = 0
	tr1 = 0
	for i in range(n - 1):
		if s + arr[i] >= 0:
			s += arr[i]
			tr1 = max(tr1, s)
		else:
			s = 0
	tr2 = 0
	s = 0
	for i in range(1, n):
		if s + arr[i] >= 0:
			s += arr[i]
			tr2 = max(tr1, s)
		else:
			s = 0
	tr = max(tr1, tr2)
	if total > tr:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	input()
	ns = [int(i) for i in input().split()]
	s = sum(ns)
	ss = 0
	ok = False
	for i in ns[:-1]:
		ss += i
		if ss < 0:
			ss = 0
		if ss >= s:
			print('NO')
			ok = True
			break
	if not ok:
		ss = 0
		for i in ns[1:]:
			ss += i
			if ss < 0:
				ss = 0
			if ss >= s:
				print('NO')
				ok = True
				break
	if not ok:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = 'YES'
	a = b = 0
	for i in range(n - 1):
		a += l[i]
		b += l[n - i - 1]
		if a < 1 or b < 1:
			s = 'NO'
			break
	print(s)


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	k = sum(array)
	(k1, k2) = (0, 0)
	this = 0
	for i in array[:-1]:
		this += i
		k1 = max(k1, this)
		if this < 0:
			this = 0
	this = 0
	for i in array[1:]:
		this += i
		k2 = max(k2, this)
		if this < 0:
			this = 0
	if max(k1, k2) >= k:
		print('NO')
	else:
		print('YES')


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = sum(a)
	s = []
	s1 = 0
	for i in range(n):
		s.append(s1)
		s1 += a[i]
	s.append(s1)
	f = False
	for i in range(n):
		if s[i] <= 0 and i > 0:
			f = True
		elif s[n] - s[i + 1] <= 0 and i < n - 1:
			f = True
	if f == False:
		print('YES')
	else:
		print('NO')


import math
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def check(A, N):
	t = 0
	u = 0
	for i in range(len(A)):
		t += A[i]
		if t <= 0:
			return False
	for i in range(len(A) - 1, -1, -1):
		u += A[i]
		if u <= 0:
			return False
	return True
for _ in range(int(input())):
	N = int(input())
	A = alele()
	print('YES') if check(A, N) else print('NO')


def Ans(l, s, n):
	sm = l[s]
	ms = sm
	i = s + 1
	while i < n:
		sm = max(l[i], l[i] + sm)
		if sm > ms:
			ms = sm
		i += 1
	return ms
t = int(input())
for _ in range(t):
	flag = 0
	n = int(input())
	l = list(map(int, input().split()))
	total = sum(l)
	s1 = Ans(l, 0, n - 1)
	if s1 >= total:
		print('NO')
		continue
	s2 = Ans(l, 1, n)
	if s2 >= total:
		print('NO')
		continue
	print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 'YES'
	cur = 0
	for i in range(n - 1):
		cur += a[i]
		if cur <= 0:
			ans = 'NO'
	cur = 0
	for i in range(n - 1, 0, -1):
		cur += a[i]
		if cur <= 0:
			ans = 'NO'
	print(ans)


def happy():
	n = int(input())
	l = list(map(int, input().split()))
	sums = 0
	for i in range(0, n):
		sums += l[i]
		if sums <= 0:
			return 'NO'
	sums = 0
	for i in range(n - 1, -1, -1):
		sums += l[i]
		if sums <= 0:
			return 'NO'
	return 'YES'
for i in range(int(input())):
	print(happy())


import sys

def I():
	return sys.stdin.readline().rstrip()

def mx(a):
	s = 0
	m = None
	for i in a[:-1]:
		s += i
		if m:
			m = max(m, s)
		else:
			m = s
		if s < 0:
			s = 0
	return m
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	f = max(mx(a), mx(a[::-1])) >= sum(a)
	print('NO' if f else 'YES')


def sol():
	x = int(input())
	s = list(map(int, input().split()))
	sm = 0
	for n in s:
		sm += n
		if sm <= 0:
			print('NO')
			return
	s.reverse()
	sm = 0
	for n in s:
		sm += n
		if sm <= 0:
			print('NO')
			return
	print('YES')
for n in range(int(input())):
	sol()


def solve(a):
	mms = 0
	ms = sum(a)
	for i in range(len(a) - 1):
		mms += a[i]
		if mms <= 0 or mms >= ms:
			return 'NO'
	return 'YES'
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a))


t = int(input())
arr = []
for _ in range(t):
	arr.append(int(input()))
	arr.append(list(map(int, input().strip().split())))
for s in range(t):
	(n, idx) = (arr[2 * s], 2 * s + 1)
	(s, sm, mx_sm, start, ysr, end) = (0, 0, 0, 0, 0, 0)
	for i in range(n):
		ysr += arr[idx][i]
		sm += arr[idx][i]
		if sm <= 0:
			sm = 0
			s = i + 1
		if sm > mx_sm:
			(start, end) = (s, i)
			mx_sm = sm
	if start == 0 and end == n - 1 or mx_sm < ysr:
		print('YES')
	else:
		print('NO')


def sovle():
	n = int(input())
	a = [int(i) for i in input().split()]
	sum = 0
	for i in range(0, n):
		sum += a[i]
		if sum <= 0:
			return 0
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += a[i]
		if sum <= 0:
			return 0
	return 1

def main():
	t = int(input())
	while t:
		t -= 1
		print('YES' if sovle() == 1 else 'NO')
main()


kl = int(input())
for l in range(kl):
	n = int(input())
	a = [int(i) for i in input().split()]
	(sl, sp) = (0, 0)
	pr = 1
	for i in range(n - 1):
		sl += a[i]
		sp += a[n - 1 - i]
		if sl <= 0 or sp <= 0:
			pr = 0
			print('NO')
			break
	if pr:
		print('YES')


def maxsum(a, i, j, s):
	ind1 = i
	ind2 = i
	s1 = 0
	for k in range(i, j + 1):
		s1 += a[k]
		if s1 >= s:
			return False
		if s1 <= 0:
			s1 = 0
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	s1 = 0
	if n == 1:
		print('YES')
	elif maxsum(a, 0, n - 2, s) and maxsum(a, 1, n - 1, s):
		print('YES')
	else:
		print('NO')


tc = int(input())
for i in range(tc):
	n = int(input())
	flag = 1
	inp = [int(var) for var in input().split()]
	sum = 0
	for i in inp[:n - 1]:
		sum += i
		if sum <= 0:
			flag = 0
			break
	sum = 0
	for i in inp[-1:0:-1]:
		sum += i
		if sum <= 0:
			flag = 0
			break
	print('YES') if flag else print('NO')


t = int(input())

def woi(a, n):
	sum = 0
	for i in range(n):
		sum += a[i]
		if sum <= 0:
			return 0
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += a[i]
		if sum <= 0:
			return 0
	return 1
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	if woi(a, n):
		print('YES')
	else:
		print('NO')


def kandane(ar):
	(s, ms) = (0, 1e-08)
	for i in range(len(ar)):
		s += ar[i]
		if ms < s:
			ms = s
		if s < 0:
			s = 0
	return ms
t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	rsum = sum(ar)
	f1 = kandane(ar[:-1])
	f2 = kandane(ar[1:])
	ms = max(f1, f2)
	if rsum > ms:
		print('YES')
	else:
		print('NO')


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far

def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		total = sum(arr)
		sum1 = maxSubArraySum(arr[:n - 1], n - 1)
		sum2 = maxSubArraySum(arr[1:], n - 1)
		if total > max(sum1, sum2):
			ans.append('YES')
		else:
			ans.append('NO')
	for i in ans:
		print(i)
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	st = 0
	s1 = 0
	st1 = 0
	u = 0
	for i in range(0, n):
		s = a[i] + st
		st = s
		if s <= 0:
			u = 1
			break
		s1 = a[-(i + 1)] + st1
		st1 = s1
		if s1 <= 0:
			u = 1
			break
	if u == 1:
		print('NO')
	else:
		print('YES')


def mxsm(lst):
	mx = 0
	j = 0
	for x in lst:
		j = max(j + x, 0)
		mx = max(mx, j)
	return mx
t = int(input())
for _ in range(t):
	_ = input()
	l = list(map(int, input().split()))
	if sum(l) > max(mxsm(l[:-1]), mxsm(l[1:])):
		print('YES')
	else:
		print('NO')


import math

def max_subarray(k, f):
	ce = math.floor(len(k) / 2)
	le = len(k)
	if len(k) == 1:
		return k[0]
	else:
		max_s1 = max_subarray(k[0:ce], f)
		max_s2 = max_subarray(k[ce:le + 1], f)
		q = k[ce]
		i_max = ce
		sum_i = 0
		for i in range(0, ce + 1):
			sum_i += k[ce - i]
			if q < sum_i:
				q = sum_i
				i_max = ce - i
		j_max = ce
		q1 = q
		sum_j = 0
		q = 0
		for j in range(ce, le - int(i_max == 0 and len(k) == f)):
			sum_j += k[j]
			if q < sum_j:
				q = sum_j
				j_max = j + 1
		return max(q1 + q - k[ce], max_s1, max_s2)
x = list(map(int, input().split()))
y = []
for i in range(x[0]):
	tmp = input()
	y.append(list(map(int, input().split())))
for i in range(x[0]):
	nnn = max_subarray(y[i][:], len(y[i]))
	if nnn < sum(y[i][:]):
		print('YES')
	else:
		print('NO')


def func(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(a, b) = (func(l[:-1], n - 1), func(l[1:], n - 1))
	s = sum(l)
	if s > a and s > b:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	a = b = 0
	for i in range(n):
		a += li[i]
		b += li[n - i - 1]
		if a <= 0 or b <= 0:
			print('NO')
			break
	else:
		print('YES')


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	max1 = maxSubArraySum(l[:-1], len(l) - 1)
	max2 = maxSubArraySum(l[1:], len(l) - 1)
	max_sum = max(max1, max2)
	SUM = sum(l)
	if SUM > max_sum:
		print('YES')
	else:
		print('NO')


INF = 10 ** 10

def main():
	n = get_int()
	li = get_list()

	def get_max(li):
		dp = [0]
		for i in li:
			dp.append(max(dp[-1] + i, i))
		return max(dp[1:])
	maxi = max(get_max(li[1:]), get_max(li[:n - 1]))
	if maxi < sum(li):
		print('YES')
	else:
		print('NO')
import sys
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	sum1 = sum(s)
	sum2 = 0
	max2 = 0
	max1 = 0
	for j in range(n - 1):
		max1 = max1 + s[j]
		if max2 < max1:
			max2 = max1
		if max1 < 0:
			max1 = 0
	max3 = 0
	max1 = 0
	for j in range(1, n):
		max1 = max1 + s[j]
		if max3 < max1:
			max3 = max1
		if max1 < 0:
			max1 = 0
	max2 = max(max2, max3)
	if max2 < sum1:
		print('YES')
	else:
		print('NO')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]

def kadane(a):
	cur = a[0]
	ans = cur
	for i in range(1, len(a)):
		cur = max(cur + a[i], a[i])
		ans = max(ans, cur)
	return ans
for _ in range(int(input())):
	n = int(input())
	a = array()
	if kadane(a[1:]) >= sum(a) or kadane(a[:-1]) >= sum(a):
		print('NO')
	else:
		print('YES')


from os import path
import sys
from math import ceil, floor, gcd, log2
from collections import defaultdict, Counter
maxx = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
else:
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	n = I()
	ls = lint()
	ans = 'YES'
	(s1, s2) = (0, 0)
	for i in range(n - 1):
		s1 += ls[i]
		if s1 <= 0:
			ans = 'NO'
	for i in range(n - 1, 0, -1):
		s2 += ls[i]
		if s2 <= 0:
			ans = 'NO'
	print(ans)


def max_subarray(numbers):
	best_sum = 0
	best_start = best_end = 0
	current_sum = 0
	for (current_end, x) in enumerate(numbers):
		if current_sum <= 0:
			current_start = current_end
			current_sum = x
		else:
			current_sum += x
		if current_sum > best_sum:
			best_sum = current_sum
			best_start = current_start
			best_end = current_end + 1
	return (best_sum, best_start, best_end)

def main():
	t = int(input())
	while t:
		t -= 1
		_ = int(input())
		a = list(map(int, input().split()))
		x = sum(a)
		(y, s, e) = max_subarray(a)
		if s == 0 and e == len(a) or x > y:
			print('YES')
		else:
			print('NO')
main()


for t in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	(i, maxsum, maxsufsum) = (0, 0, 0)
	while i < n - 1:
		maxsufsum = max(0, maxsufsum + A[i])
		maxsum = max(maxsum, maxsufsum)
		i += 1
	total = sum(A)
	new = total - A[0]
	for i in range(1, n):
		maxsum = max(maxsum, new)
		new = new - A[i]
	if total > maxsum:
		print('YES')
	else:
		print('NO')


def eat(n, l):
	s1 = sum(l)
	sf = 0
	sb = 0
	for i in range(n):
		sf += l[i]
		sb += l[n - i - 1]
		if sf <= 0 or sb <= 0:
			return 'NO'
	return 'YES'
t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l.append(s)
for j in l:
	print(eat(len(j), j))


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	(c, x, y, k, l) = (0, 0, 0, -1, 0)
	for (i, v) in enumerate(a):
		c += v
		if x >= c:
			x = c
			k = i
		if y < c - x:
			y = c - x
			l = i - k
	print('NO' if l < n else 'YES')


def kadane(a):
	n = len(a)
	dp = [0 for _ in range(n)]
	dp[0] = a[0]
	for i in range(1, n):
		dp[i] = max(a[i] + dp[i - 1], a[i])
	return max(dp)
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	y = sum(a)
	d = max(kadane(a[1:]), kadane(a[:n - 1]))
	if y > d:
		ans.append('YES')
	else:
		ans.append('NO')
ans = '\n'.join([str(i) for i in ans])
print(ans)


t = int(input())
count = 0
count1 = 0
c = 0
for i in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	leng = n - 1
	for i in range(leng):
		count += m[i]
		count1 += m[leng - i]
		if count < 1 or count1 < 1:
			c += 1
			break
	if c != 1:
		print('YES')
	else:
		print('NO')
	count = 0
	count1 = 0
	c = 0


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	c = 0
	k = 0
	for j in range(len(l)):
		c += l[j]
		k += l[len(l) - j - 1]
		l1.append(c)
		l1.append(k)
	cf = 0
	for j in l1:
		if j <= 0:
			cf = 1
	if cf == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sum = 0
	f = 0
	for i in range(n):
		sum += arr[i]
		if sum <= 0:
			f = 1
			print('NO')
			break
	if f == 1:
		continue
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += arr[i]
		if sum <= 0:
			f = 1
			print('NO')
			break
	if f == 0:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s1 = 0
	s2 = 0
	flag = False
	for j in range(n):
		s1 = s1 + a[j]
		s2 = s2 + a[n - j - 1]
		if s1 <= 0 or s2 <= 0:
			flag = True
	if flag == False:
		print('YES')
	else:
		print('NO')


def solve():
	s = 0
	for i in range(n):
		s += v[i]
		if s <= 0:
			return 0
	s = 0
	for i in range(n - 1, -1, -1):
		s += v[i]
		if s <= 0:
			return 0
	return 1
t = int(input())
while t:
	n = int(input())
	v = [int(x) for x in input().split()]
	if solve() == 0:
		print('NO')
	else:
		print('YES')
	t -= 1


from sys import stdin, stdout
for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in stdin.readline().split()]
	val = sum(a)
	a_copy = a.copy()
	a_copy.sort()
	s = [0 for x in range(n)]
	s[0] = a[0]
	for i in range(1, n):
		s[i] = s[i - 1] + a[i]
	pre = [0 for x in range(n)]
	pre[-1] = a[-1]
	for j in range(-2, -(n + 1), -1):
		pre[j] = pre[j + 1] + a[j]
	s.pop()
	pre.pop(0)
	s.sort()
	pre.sort()
	if a_copy[0] >= 0 and n > 1 and (s[-1] != 0 or pre[-1] != 0):
		print('YES')
	elif s[-1] >= val or pre[-1] >= val:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
from itertools import accumulate
t = int(input())
for test in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	S = list(accumulate(A))
	for s in S:
		if s <= 0:
			print('NO')
			break
	else:
		B = A[::-1]
		S = list(accumulate(B))
		for s in S:
			if s <= 0:
				print('NO')
				break
		else:
			print('YES')


import math

def maxSubArraySum(a, size):
	max_so_far = -1 * math.inf - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = maxSubArraySum(a[1:], n - 1)
	c = maxSubArraySum(a[:-1], n - 1)
	if b < sum(a) and c < sum(a):
		print('YES')
	else:
		print('NO')


from sys import stdin
t = int(stdin.readline().strip())

def f():
	s = 0
	for i in range(n):
		s += a[i]
		if s <= 0:
			return False
	s = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s <= 0:
			return False
	return True
for _ in range(t):
	n = int(stdin.readline().strip())
	a = list(map(int, stdin.readline().split()))
	print('YES' if f() else 'NO')


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	total = sum(a)
	s = [0]
	for i in range(n):
		s.append(s[-1] + a[i])
	last_ind = 0
	min_cur = 0
	check = True
	for i in range(1, n + 1):
		if s[i] - min_cur >= total and (i != n or last_ind != 0):
			print('NO')
			check = False
			break
		if s[i] < min_cur:
			min_cur = s[i]
			last_ind = i
		elif s[i] == min_cur:
			last_ind = i
	if check:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	sm = sum(a)
	mx = 0
	cur_sm = 0
	for i in range(0, n - 1):
		cur_sm += a[i]
		if cur_sm < 0:
			cur_sm = 0
		mx = max(mx, cur_sm)
	if mx < sm:
		mx = 0
		cur_sm = 0
		for i in range(1, n):
			cur_sm += a[i]
			if cur_sm < 0:
				cur_sm = 0
			mx = max(mx, cur_sm)
	print('YES' if mx < sm else 'NO')


def mssl(l):
	best = cur = 0
	curi = starti = besti = 0
	for (ind, i) in enumerate(l):
		if cur + i > 0:
			cur += i
		else:
			(cur, curi) = (0, ind + 1)
		if cur > best:
			(starti, besti, best) = (curi, ind + 1, cur)
	return (starti, besti, best)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	taste = sum(a)
	(start, end, best) = mssl(a)
	if end - start == len(a) or best < taste:
		print('YES')
	else:
		print('NO')


def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -10000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -1000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def maxSubArraySum(arr, l, h):
	if l == h:
		return arr[l]
	m = (l + h) // 2
	return max(maxSubArraySum(arr, l, m), maxSubArraySum(arr, m + 1, h), maxCrossingSum(arr, l, m, h))
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	(s1, s2) = (maxSubArraySum(a, 0, n - 2), maxSubArraySum(a, 1, n - 1))
	if s1 >= y or s2 >= y:
		print('NO')
	else:
		print('YES')


x = int(input())
for _ in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	l = a[0]
	c = a[0]
	k = [0]
	p = sum(a)
	for i in range(1, n):
		if c + a[i] >= a[i] and c + a[i] != 0:
			k.append(i)
			c = max(c + a[i], a[i])
		else:
			k = [i]
			c = a[i]
		if c > l:
			l = max(l, c)
		if l >= p:
			break
	if len(k) == n:
		l -= 1
	if l < sum(a):
		print('YES')
	else:
		print('NO')


def eatit(n, a):
	yasser = sum(a)
	cs = 0
	ms = 0
	l = 0
	cl = 0
	for i in range(n):
		cs += a[i]
		l += 1
		if cs <= 0:
			cs = 0
			l = 0
			continue
		if cs > ms:
			ms = cs
			cl = l
	if ms < yasser:
		return 'YES'
	elif cl != n:
		return 'NO'
	else:
		return 'YES'
t = int(input())
a = []
for i in range(t):
	b = int(input())
	c = list(map(int, input().split(' ')))
	a.append([b, c])
for x in a:
	print(eatit(*x))


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	y = a[0]
	cm = a[0]
	m = a[0]
	c = 1
	cmax = 1
	for i in a[1:]:
		if cm + i > i:
			cm = cm + i
			c += 1
		else:
			cm = i
			c = 1
		if cm > m:
			m = cm
			cmax = c
		elif cm == m:
			cmax = min(cmax, c)
		y += i
	if y > m:
		print('YES')
	elif y < m:
		print('NO')
	elif cmax == n:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	for i in a:
		s += i
		if s <= 0:
			return 'NO'
	s = 0
	for i in a[::-1]:
		s += i
		if s <= 0:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	print(solve())


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	dp = [0 for i in range(n)]
	count = 0
	for i in range(n):
		if i == 0:
			dp[i] = li[i]
			continue
		dp[i] = max(dp[i - 1] + li[i], li[i])
		if dp[i] == dp[i - 1] + li[i] and dp[i] > li[i]:
			count += 1
		if count == n - 1:
			dp[i] = li[i]
	sumi = sum(li)
	poss = 1
	for i in range(n):
		if dp[i] >= sumi:
			poss = 0
			break
	if poss:
		print('YES')
	else:
		print('NO')


testcase = int(input())
for i in range(testcase):
	n = int(input())
	lists = list(map(int, input().split()))
	(p, s) = (0, 0)
	flag = False
	for i in range(n):
		p += lists[i]
		s += lists[n - 1 - i]
		if p <= 0 or s <= 0:
			print('NO')
			flag = True
			break
	if not flag:
		print('YES')


t = int(input())

def max_subarray(arr):
	max_ending = max_current = arr[0]
	for i in arr[1:]:
		max_ending = max(i, max_ending + i)
		max_current = max(max_current, max_ending)
	return max_current
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if max_subarray(a[1:]) < sum(a) and max_subarray(a[:-1]) < sum(a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s1 = l[0]
	s2 = l[n - 1]
	f1 = f2 = False
	for i in range(1, n):
		if s1 <= 0:
			f1 = True
			break
		s1 += l[i]
	for j in range(n - 2, -1, -1):
		if s2 <= 0:
			f2 = True
			break
		s2 += l[j]
	if f1 or f2:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from collections import defaultdict
input = stdin.readline
print = stdout.write
for t in range(int(input())):
	n = int(input())
	A = [int(x) for x in input().split()]
	(i, maxsum, maxsufsum, total) = (0, 0, 0, 0)
	while i < n - 1:
		total += A[i]
		maxsufsum = max(0, maxsufsum + A[i])
		maxsum = max(maxsum, maxsufsum)
		i += 1
	total = total + A[n - 1]
	new = total - A[0]
	for i in range(1, n):
		maxsum = max(maxsum, new)
		new = new - A[i]
	if total > maxsum:
		print('YES\n')
	else:
		print('NO\n')


def maxSubArraySum(a):
	size = len(a)
	max_so_far = -10000000000
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input())
while t > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	s = 0
	ss = maxSubArraySum(a[1:])
	se = maxSubArraySum(a[:-1])
	if ss > se:
		s = ss
	else:
		s = se
	s1 = sum(a)
	if s1 > s:
		print('YES')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	f = input()
	l = [int(i) for i in input().split()]
	f = 0
	s = ss = 0
	z = sum(l)
	n = 0
	left = right = 0
	for i in range(len(l)):
		left += l[i]
		right += l[len(l) - i - 1]
		if left <= 0 or right <= 0:
			f = 1
			break
	print('NO' if f == 1 else 'YES')


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		y = sum(a)
		s = 0
		flag = 0
		for i in range(n - 1):
			if a[i] < 0:
				if s >= y:
					flag = 1
					break
				if s + a[i] > 0:
					s += a[i]
				else:
					flag = 1
					break
			else:
				s += a[i]
				if s >= y:
					flag = 1
					break
		if flag == 1:
			print('NO')
		else:
			s = 0
			for i in range(1, n):
				if a[i] < 0:
					if s >= y:
						flag = 1
						break
					if s + a[i] > 0:
						s += a[i]
					else:
						s = 0
				else:
					s += a[i]
					if s >= y:
						flag = 1
						break
			if flag == 1:
				print('NO')
		if flag == 0:
			print('YES')
main()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	adel = sum(l)
	max_start = max_end = -10 ** 20
	max_start_temp = max_end_temp = 0
	for i in range(n - 1):
		max_start_temp = max_start_temp + l[i]
		max_end_temp = max_end_temp + l[i + 1]
		if max_start < max_start_temp:
			max_start = max_start_temp
		if max_end < max_end_temp:
			max_end = max_end_temp
		if max_start_temp < 0:
			max_start_temp = 0
		if max_end_temp < 0:
			max_end_temp = 0
	print('YES' if adel > max_start and adel > max_end else 'NO')


t = int(input())
for _ in range(t):
	(n, l) = (int(input()), list(map(int, input().split())))
	Yasser = sum(l)
	maxsofar = float('-inf')
	maxendinghere = 0
	count = 0
	for i in range(1, n):
		maxendinghere = maxendinghere + l[i]
		if maxendinghere < 0:
			maxendinghere = 0
		maxsofar = max(maxsofar, maxendinghere)
	maxendinghere = 0
	for i in range(n - 1):
		maxendinghere = maxendinghere + l[i]
		if maxendinghere < 0:
			maxendinghere = 0
		maxsofar = max(maxsofar, maxendinghere)
	Adel = maxsofar
	if Yasser > Adel:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	yasser = sum(arr)
	adel = 0
	max_length = n - 1
	left = 0
	cur = 0
	for right in range(n):
		cur += arr[right]
		if right - left + 1 <= max_length:
			if cur > 0:
				adel = max(adel, cur)
			else:
				while left <= right:
					cur -= arr[left]
					left += 1
					adel = max(adel, cur)
		else:
			cur -= arr[left]
			left += 1
			adel = max(adel, cur)
	print('YES' if yasser > adel else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	copia = a[:]
	soma = sum(a)
	last = a[-1]
	for i in range(1, len(a)):
		copia[i] = max(copia[i], copia[i] + copia[i - 1])
	for i in range(2, len(a)):
		a[i] = max(a[i], a[i] + a[i - 1])
	copia.pop()
	copia.append(a[-1])
	a = copia
	happy = True
	for i in a:
		if i >= soma:
			happy = False
			break
	if happy:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = sum(a)
	m = []
	if max(a) < 0:
		print('NO')
	else:
		maa = -100000000
		s = 0
		size = len(a)
		c = 0
		cc = 0
		for i in range(0, size):
			if a[i] >= 0:
				s += a[i]
				c += 1
			else:
				if maa < s:
					maa = s
					cc = c
				if s + a[i] <= 0:
					s = 0
					c = 0
				else:
					s = s + a[i]
					c += 1
		if maa < s:
			maa = s
			cc = c
		if a[0] == 0 and len(set(a)) == 1:
			print('NO')
		elif maa == k:
			if cc == len(a):
				print('YES')
			else:
				print('NO')
		elif maa < k:
			print('YES')
		else:
			print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline().strip())
	tastes = [int(i) for i in sys.stdin.readline().split()]
	A = sum(tastes)
	cur = 0
	best = 0
	for i in tastes[:-1]:
		cur += i
		best = max(best, cur)
		if cur < 0:
			cur = 0
	cur = 0
	for i in tastes[1:]:
		cur += i
		best = max(best, cur)
		if cur < 0:
			cur = 0
	if A > best:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	a = [int(v) for v in input().split()]
	(s, f, su) = (0, 1, sum(a))
	for i in range(n - 1):
		s += a[i]
		if s <= 0 or s >= su:
			print('NO')
			f = 0
			break
	if f:
		print('YES')


def findMaxSum(a):
	ans = a[0]
	summ = 0
	for r in range(len(a)):
		summ += a[r]
		ans = max(ans, summ)
		summ = max(summ, 0)
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 2:
		if a[0] > 0 and a[1] > 0:
			print('YES')
		else:
			print('NO')
	else:
		maximum = max(findMaxSum(a[:-1]), findMaxSum(a[1:]))
		all_sum = sum(a)
		if all_sum > maximum:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	adel_count = local_adel_count = 0
	local_adel = adel = -float('inf')
	for var in arr:
		if var >= var + local_adel:
			local_adel = var
			local_adel_count = 1
		else:
			local_adel += var
			local_adel_count += 1
		if local_adel > adel:
			adel = local_adel
			adel_count = local_adel_count
	if sum(arr) > adel:
		print('YES')
	elif sum(arr) == adel:
		print('NO') if n != adel_count else print('YES')
	else:
		print('NO')


t = int(input())
for j in range(0, t):
	x = int(input())
	v = list(map(int, input().split()))
	Sum = sum(v)
	(LM, GM) = (v[0], v[0])
	for i in range(1, len(v) - 1):
		LM = max(LM + v[i], v[i])
		if LM > GM:
			GM = LM
	(LM2, GM2) = (v[1], v[1])
	for i in range(2, len(v)):
		LM2 = max(LM2 + v[i], v[i])
		if LM2 > GM2:
			GM2 = LM2
	if Sum > GM and Sum > GM2:
		print('YES')
	else:
		print('NO')


def solved(lst, n):
	if lst[0] < 0 or lst[n - 1] < 0:
		return False
	a = 0
	c = 0
	b = sum(lst)
	for i in range(n - 1):
		a += lst[i]
		if a >= b:
			return False
		if a < 0:
			a = 0
	for i in range(1, n):
		c += lst[i]
		if c >= b:
			return False
		if c < 0:
			c = 0
	return True
for _ in range(int(input().strip())):
	n = int(input().strip())
	lst_number = list(map(int, input().strip().split()))
	if solved(lst=lst_number, n=n):
		print('YES')
	else:
		print('NO')


import bisect

def find(arr, n, k):
	ans = 0
	for i in range(1, n):
		arr[i] += arr[i - 1]
		if arr[i] >= k:
			ans += 1
	if arr[0] > k:
		ans += 1
	arr = sorted(arr)
	for i in range(n):
		ans += n - bisect.bisect_left(arr, arr[i] + k)
	return ans
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	sm = sum(a)
	res = find(a, n, sm)
	if res > 1:
		print('NO')
	else:
		print('YES')


def happy(n):
	a = list(map(int, input().split()))
	s = 0
	for j in range(0, n - 1):
		s += a[j]
		if s <= 0:
			return False
	s1 = 0
	for k in range(n - 1, 0, -1):
		s1 += a[k]
		if s1 <= 0:
			return False
	return True
t = int(input())
for i in range(t):
	nos = int(input())
	if happy(nos):
		print('YES')
	else:
		print('NO')


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -10000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -1000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def fun(a, l, r):
	if r - l == 0:
		return (a[l], l, r)
	else:
		mid = (r - l) // 2 + l
		x = fun(a, l, mid)
		y = fun(a, mid + 1, r)
		i = x[1]
		j = y[2]
		s1 = maxCrossingSum(a, l, mid, r)
		s2 = x[0]
		s3 = y[0]
		if s3 >= s1 and s3 >= s2:
			return y
		elif s2 >= s1 and s2 >= s3:
			return x
		else:
			return (s1, i, j)
t = read_int()
for i in range(t):
	n = read_int()
	a = read_int_line()
	f = False
	a1 = sum(a)
	a2 = fun(a, 0, n - 1)
	if a2[0] < a1 or (a1 == a2[0] and a2[1] == 0 and (a2[2] == n - 1)):
		print('YES')
	else:
		print('NO')


def maxSub(lst):
	local_max = 0
	global_max = -2 ** 32
	for i in range(len(lst)):
		local_max = max(lst[i], lst[i] + local_max)
		if local_max > global_max:
			global_max = local_max
	return global_max

def solve(lst):
	yasr = sum(lst)
	adel = max(maxSub(lst[1:]), maxSub(lst[:-1]))
	if yasr > adel:
		print('YES')
	else:
		print('NO')

def main():
	t = int(input())
	for i in range(t):
		n = input()
		lst = [int(j) for j in input().split()]
		solve(lst)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	dp = [0] * n
	dp[0] = a[1]
	m = dp[0]
	for i in range(2, n):
		dp[i - 1] = max(dp[i - 2] + a[i], a[i])
		m = max(m, dp[i - 1])
	dp[0] = a[0]
	m = max(m, dp[0])
	for i in range(1, n - 1):
		dp[i] = max(dp[i - 1] + a[i], a[i])
		m = max(m, dp[i])
	if m >= s:
		print('NO')
	else:
		print('YES')


t = int(input())
for z in range(t):
	n = int(input())
	line = input()
	b = line.split()
	a = []
	for j in b:
		a.append(int(j))
	value = 0
	sum = 0
	size = 0
	for v in a:
		sum += v
		size += 1
		if sum > 0:
			if value < sum and size < n:
				value = sum
		else:
			sum = 0
			size = 0
	if value == 0:
		value = a[0]
		for v in a:
			if value < v:
				value = v
	sum = 0
	for v in a:
		sum += v
	if sum > value:
		print('YES')
	else:
		print('NO')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections
maxint = 99999999999999999

def maxSubArraySum(a, size):
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	zz = 0
	for _ in range(ri()):
		n = ri()
		a = ria()
		c = sum(a)
		z1 = a[1:]
		z2 = a[:n - 1]
		k = max(maxSubArraySum(z1, n - 1), maxSubArraySum(z2, n - 1))
		if k >= c:
			ws('NO')
		else:
			ws('YES')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for i in range(t):
	n = int(input())
	A = [int(j) for j in input().split()]
	if A[0] <= 0 or A[-1] <= 0:
		print('NO')
	else:
		summ = 0
		An = []
		for k in range(n):
			a = A[k]
			if summ * a >= 0:
				summ += a
			else:
				An.append(summ)
				summ = a
		An.append(summ)
		if len(An) == 1:
			print('YES')
		else:
			sum1 = An[0]
			fl = True
			ind = 1
			maxind = len(An)
			res = True
			while fl:
				a1 = An[ind]
				sum1 += a1
				if sum1 <= 0:
					fl = False
					res = False
				else:
					ind += 1
					if ind == maxind:
						fl = False
			if res:
				sum2 = An[-1]
				fl = True
				ind = -2
				maxind = -1 * len(An) - 1
				while fl:
					a2 = An[ind]
					sum2 += a2
					if sum2 <= 0:
						fl = False
						res = False
					else:
						ind -= 1
						if ind == maxind:
							fl = False
				if res:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sm = sum(arr)
	ans = arr[0]
	s = 0
	for r in range(n - 1):
		s += arr[r]
		ans = max(s, ans)
		s = max(s, 0)
	sss = ans
	ans = arr[-1]
	s = 0
	for l in range(n - 1, 0, -1):
		s += arr[l]
		ans = max(s, ans)
		s = max(s, 0)
	ans = max(ans, sss)
	if sm > ans:
		print('YES')
	else:
		print('NO')


def kadane(a, n):
	dp1 = [a[0]]
	for i in range(1, n - 1):
		dp1.append(max(dp1[-1] + a[i], a[i]))
	dp2 = [a[1]]
	for i in range(2, n):
		dp2.append(max(dp2[-1] + a[i], a[i]))
	mx1 = max(dp1)
	mx2 = max(dp2)
	return max(mx1, mx2)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	s = sum(a)
	val = kadane(a, n)
	if s > val:
		print('YES')
	else:
		print('NO')


def getInfo(n, a):
	s = 0
	for i in a:
		s += i
		if s <= 0:
			return 0
	s = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s <= 0:
			return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a[0] < 0 or a[-1] < 0:
		print('NO')
	else:
		updt = getInfo(n, a)
		if updt:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	A = [int(j) for j in input().split()]
	X = sum(A)
	Y1 = 0
	Y2 = 0
	result = 'YES'
	for j in range(n - 1):
		Y1 += A[j]
		Y2 += A[-j - 1]
		if Y1 >= X:
			result = 'NO'
		if Y2 >= X:
			result = 'NO'
	print(result)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	f = 0
	for i in l:
		s += i
		if s <= 0:
			f = 1
			break
	s = 0
	for i in l[::-1]:
		s += i
		if s <= 0:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	i = 0
	s = 0
	x = []
	f = 0
	com = sum(a)
	if n == 2:
		if a[0] > 0 and a[1] > 0:
			print('YES')
		elif a[0] <= 0 and a[1] <= 0:
			print('NO')
		elif a[0] * a[1] < 0:
			print('NO')
	else:
		while i < n - 1:
			if a[i] > 0:
				s += a[i]
				x.append(s)
				if s >= com:
					break
			elif s + a[i] > 0:
				s += a[i]
				x.append(s)
			else:
				s = 0
			i += 1
		y = []
		i = n - 1
		s = 0
		f = 0
		if i == 0:
			y.append(a[0])
		while i > 0:
			if a[i] > 0:
				s += a[i]
				y.append(s)
				if s >= com:
					break
			elif s + a[i] > 0:
				s += a[i]
				y.append(s)
			else:
				s = 0
			i -= 1
		if len(y) == 0:
			y.append(0)
		if len(x) == 0:
			x.append(0)
		if len(y) == 0 and len(x) == 0:
			print('NO')
		else:
			y = max(y)
			x = max(x)
			if y >= com or x >= com:
				print('NO')
			else:
				print('YES')


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
import bisect as bi
import heapq

def I():
	return int(input())

def In():
	return map(int, input().split())

def main():
	try:
		for _ in range(I()):
			n = I()
			l = list(In())
			(t1, t2, q) = (0, 0, 0)
			for x in range(n):
				t1 += l[x]
				t2 += l[-(x + 1)]
				if t1 <= 0:
					q = 1
				if t2 <= 0:
					q = 1
			if q == 1:
				print('NO')
			else:
				print('YES')
	except:
		pass
M = 998244353
P = 1000000007
main()


n = int(input())
for i in range(n):
	num = int(input())
	list_of_choices = list(map(int, input().split()))
	sum_j = 0
	flag = False
	for j in range(num - 1):
		sum_j += list_of_choices[j]
		if sum_j <= 0:
			flag = True
			break
	else:
		sum_k = 0
		for k in range(num - 1, 0, -1):
			sum_k += list_of_choices[k]
			if sum_k <= 0:
				flag = True
				break
	if flag:
		print('NO')
	else:
		print('YES')


def cad(L):
	N = len(L)
	sumsofar = 0
	su = 0
	last = 0
	for i in range(len(L)):
		su += L[i]
		if su < 0:
			su = 0
		sumsofar = max(sumsofar, su)
	return sumsofar

def f(L):
	return max(cad(L[1:]), cad(L[:len(L) - 1]))
T = int(input())
while T > 0:
	T -= 1
	N = int(input())
	L = list(map(int, input().split()))
	if f(L) >= sum(L):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	A = [*map(int, input().split())]
	B = list(reversed(A))[1:]
	suma = sum(A)
	A = A[1:]
	K = [0] * (n - 1)
	maxi = -10000000
	for i in range(n - 1):
		if i == 0:
			K[i] = A[i]
		elif K[i - 1] <= 0:
			K[i] = A[i]
		else:
			K[i] = K[i - 1] + A[i]
		maxi = max(maxi, K[i])
	K = [0] * (n - 1)
	for i in range(n - 1):
		if i == 0:
			K[i] = B[i]
		elif K[i - 1] <= 0:
			K[i] = B[i]
		else:
			K[i] = K[i - 1] + B[i]
		maxi = max(maxi, K[i])
	if suma > maxi:
		print('YES')
	else:
		print('NO')


t = int(input())
maxint = 1000000000

def maxSubArraySum(a, size):
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	yasser = sum(x)
	adel = maxSubArraySum(x[0:n - 1], n - 1)
	adel1 = maxSubArraySum(x[1:n], n - 1)
	if yasser > max(adel, adel1):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	st = 0
	temp = 0
	temp2 = 0
	for k in range(0, n):
		if st <= 0:
			st = 0
			temp = k
		st = st + a[k]
		if st >= s:
			if temp != 0 or k != n - 1:
				temp2 = 1
	if temp2 == 1:
		print('NO')
	else:
		print('YES')


from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
MOD = 10 ** 9 + 7

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		r = [0]
		yasser = sum(a)
		su = 0
		for i in range(n):
			r.append(r[i] + a[i])
		rmi = min(r[:-1])
		rma = max(r[:-1])
		t = rma - rmi
		rmi = min(r[1:])
		rma = max(r[1:])
		t = max(t, rma - rmi)
		if t < max(r):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	prev = a[0]
	reduced = []
	current = 0
	for x in a:
		if (x > 0) == (prev > 0):
			current += x
		else:
			reduced.append(current)
			current = x
		prev = x
	reduced.append(current)
	if reduced[0] < 0 or reduced[-1] < 0:
		print('NO')
		continue
	best = 0
	current = 0
	stopped = False
	for x in reduced[:-1]:
		if x > 0:
			current += x
			best = max(best, current)
		elif current + x <= 0:
			best = max(best, current)
			stopped = True
			current = 0
		else:
			current += x
			best = max(best, current)
	if stopped:
		best = max(best, current + reduced[-1])
	elif current + reduced[-1] > best:
		print('YES')
		continue
	if best >= y:
		print('NO')
	else:
		print('YES')


def solve(arr):
	sum = 0
	for x in arr:
		sum = sum + x
		if sum <= 0:
			return 0
	sum = 0
	for x in reversed(arr):
		sum = sum + x
		if sum <= 0:
			return 0
	return 1
t = int(input())
while t:
	t = t - 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	sum = 0
	if solve(arr):
		print('YES')
	else:
		print('NO')


import itertools
for t in range(int(input())):
	n = int(input())
	a = list(itertools.accumulate(map(int, input().split())))
	if min(a[:-1]) <= 0 or max(a[:-1]) >= a[-1]:
		print('NO')
	else:
		print('YES')


import itertools
t = int(input())
for test in range(t):
	n = int(input())
	line1 = list(map(int, input().split()))
	yasser = sum(line1)
	curr_max = 0
	max_so_far = 0
	for i in range(n - 1):
		curr_max = max(line1[i], curr_max + line1[i])
		max_so_far = max(max_so_far, curr_max)
	curr_max1 = line1[1]
	max_so_far1 = line1[1]
	for i in range(2, n):
		curr_max1 = max(line1[i], curr_max1 + line1[i])
		max_so_far1 = max(max_so_far1, curr_max1)
	m = max(max_so_far, max_so_far1)
	if m >= yasser:
		print('NO')
	else:
		print('YES')


q = int(input())
for t in range(0, q):
	n = int(input())
	a = list(map(int, input().split()))
	su = sum(a)
	su1 = 0
	su2 = 0
	flag1 = 0
	flag2 = 0
	for i in range(0, len(a) - 1):
		su1 += a[i]
		if su1 <= 0:
			flag1 = 1
			break
	a = a[::-1]
	for i in range(0, len(a) - 1):
		su2 += a[i]
		if su2 <= 0:
			flag2 = 1
			break
	if flag1 == 0 and flag2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	happy = True
	pref_sum = 0
	suff_sum = 0
	for item in a:
		pref_sum += item
		if pref_sum <= 0:
			happy = False
			break
	if happy:
		for item in a[::-1]:
			suff_sum += item
			if suff_sum <= 0:
				happy = False
				break
	if happy:
		print('YES')
	else:
		print('NO')


def solve(n):
	li = list(map(int, input().split()))
	pref = 0
	for i in range(0, len(li) - 1):
		pref += li[i]
		if pref <= 0:
			print('NO')
			return
	suf = 0
	for i in range(len(li) - 1, -1, -1):
		suf += li[i]
		if suf <= 0:
			print('NO')
			return
	print('YES')
	return
t = int(input())
for _ in range(t):
	n = int(input())
	solve(n)


for i in range(int(input())):
	q = int(input())
	w = list(map(int, input().split()))
	e = 0
	r = 0
	for j in range(q):
		e += w[j]
		r += w[q - j - 1]
		if e <= 0 or r <= 0:
			e = -1
			break
	if e == -1:
		print('NO')
	else:
		print('YES')


test = int(input())
for z in range(test):
	amount = int(input())
	numb = list(map(int, input().split()))
	all = sum(numb)
	happy = True
	summ = 0
	for i in range(amount - 1):
		summ += numb[i]
		if summ <= 0:
			happy = False
			break
	if not happy:
		print('NO')
		continue
	else:
		summ = 0
		for i in range(amount - 1, 0, -1):
			summ += numb[i]
			if summ <= 0:
				happy = False
				break
		if not happy:
			print('NO')
			continue
	print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	z = list(map(int, input().split()))
	sm = sum(z)
	maxsum = 0
	minpref = 0
	curpref = 0
	for a in z[:-1]:
		curpref += a
		if curpref - minpref > maxsum:
			maxsum = curpref - minpref
		minpref = min(minpref, curpref)
	minpref = 0
	curpref = 0
	for a in z[1:]:
		curpref += a
		if curpref - minpref > maxsum:
			maxsum = curpref - minpref
		minpref = min(minpref, curpref)
	if maxsum < sm:
		print('YES')
	else:
		print('NO')


def solve(n, arr):
	s = 0
	for x in arr:
		s += x
		if s <= 0:
			return False
	s = 0
	for x in arr[::-1]:
		s += x
		if s <= 0:
			return False
	return True
for _ in range(int(input())):
	n = input()
	arr = list(map(int, input().split()))
	if solve(n, arr):
		print('YES')
	else:
		print('NO')


N = int(input())
for _ in range(N):
	n = int(input())
	lis = list(map(int, input().split()))
	sm = sum(lis)
	p = res = 0
	bg = 0
	for (i, v) in enumerate(lis):
		if v >= p + v:
			bg = i
		p = max(v, p + v)
		res = max(res, p)
		if res > sm:
			print('NO')
			break
		if res == sm:
			if i != n - 1:
				print('NO')
				break
			elif bg != 0:
				print('NO')
				break
	else:
		print('YES')


def solve(n):
	li = list(map(int, input().split()))
	tot = 0
	for i in range(n - 1):
		tot += li[i]
		if tot <= 0:
			return False
	tot = 0
	for i in reversed(range(1, n)):
		tot += li[i]
		if tot <= 0:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	print('YES' if solve(n) else 'NO')


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def maxSubArraySum(a, size):
	max_so_far = -INF - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = INT()
for _ in range(t):
	n = INT()
	a = LIST()
	yass = sum(a)
	adel = max(maxSubArraySum(a[1:], n - 1), maxSubArraySum(a[:-1], n - 1))
	if yass > adel:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = int(input())
	p = list(map(int, input().split()))
	yassersum = sum(p)
	start = 0
	end = 0
	s = 0
	max_so_far = -1000000000000000000
	max_ending_here = 0
	for i in range(l):
		max_ending_here = max_ending_here + p[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here <= 0:
			max_ending_here = 0
			s = i + 1
	if start == 0 and end == len(p) - 1:
		print('YES')
	elif max_so_far >= yassersum:
		print('NO')
	else:
		print('YES')


def eat(l, n):
	s = sum(l)
	f = 0
	for i in range(n):
		f = f + l[i]
		if f <= 0:
			return 'NO'
	f = 0
	for i in range(n):
		f = f + l[n - 1 - i]
		if f <= 0:
			return 'NO'
	return 'YES'
t = int(input())
for test_case in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	print(eat(l, n))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	m = sum(s)
	r = 'YES'
	(k, y) = (0, 0)
	for i in range(len(s) - 1):
		k += s[i]
		y += s[-i - 1]
		if k >= m:
			r = 'NO'
		if y >= m:
			r = 'NO'
	print(r)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	l = zzz()
	ans = 'YES'
	cur = 0
	for i in range(n):
		cur += l[i]
		if cur <= 0:
			ans = 'NO'
	cur = 0
	for i in range(1, n + 1):
		cur += l[-i]
		if cur <= 0:
			ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	s = 0
	for i in range(n):
		s += l[i]
		if s <= 0:
			break
	if s > 0:
		s = 0
		for i in range(n - 1, -1, -1):
			s += l[i]
			if s <= 0:
				break
	if s <= 0:
		print('NO')
	else:
		print('YES')


def decide():
	n = int(input())
	list1 = list(map(int, input().split()))
	psum = 0
	ssum = 0
	for i in range(n):
		psum += list1[i]
		ssum += list1[n - 1 - i]
		if psum <= 0 or ssum <= 0:
			print('NO')
			return
	print('YES')
for t in range(int(input())):
	decide()


import sys
import math
import collections

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def maxSubArraySum(a, size):
	maxint = 10 ** 15
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for t in range(int(input())):
	n = int(input())
	arr = get_list()
	yasser = sum(arr)
	m_arr = maxSubArraySum(arr, n)
	m1_arr = maxSubArraySum(arr[1:], n - 1)
	m_last_arr = maxSubArraySum(arr[:n - 1], n - 1)
	if m1_arr >= yasser or m_last_arr >= yasser:
		print('NO')
	elif m_arr > max(m1_arr, m_last_arr):
		print('YES')
	else:
		print('NO')


def maxSub(nums):
	curr = nums[0]
	maxsum = nums[0]
	behind = nums[0]
	count = 1
	for i in range(1, len(nums)):
		if nums[i] >= curr + nums[i]:
			curr = nums[i]
		else:
			curr += nums[i]
			count += 1
		maxsum = max(curr, maxsum)
	return (maxsum, count)

def Eat(nums):
	(maxsum, count) = maxSub(nums)
	if count == len(nums):
		(maxsum, count) = max(maxSub(nums[1:]), maxSub(nums[:-1]))
	yaseer = sum(nums)
	if yaseer > maxsum:
		return 'YES'
	else:
		return 'NO'

def main():
	n = eval(input())
	for i in range(n):
		k = input()
		nums = input()
		nums = [int(i) for i in nums.split()]
		print(Eat(nums))
main()


import collections
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(total, curr) = (sum(a), 0)
	(ans, i, start) = ('YES', 0, 0)
	while ans == 'YES' and i < n:
		if curr > 0:
			curr += a[i]
		else:
			curr = a[i]
			start = i
		if i - start + 1 < n and curr >= total:
			ans = 'NO'
		i += 1
	print(ans)


from sys import stdin, stdout

def main():
	r = stdin.readline
	w = stdout.write
	for t in range(int(input())):
		n = int(input())
		a = [int(x) for x in r().split()]
		(yasser, mx) = (sum(a), max(a))
		adel = mx
		(cnt, flg) = (0, 1)
		for i in range(n):
			if cnt == 0:
				(adel, cnt) = (a[i], 1)
			else:
				adel += a[i]
				cnt += 1
			if adel <= 0:
				(adel, cnt) = (mx, 0)
			if cnt < n and adel >= yasser:
				flg = 0
				break
		w('%s\n' % ['NO', 'YES'][flg])
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	total = Sum = l = r = ans = 0
	maxim = -1000000001
	for ai in a:
		total += ai
	for i in range(len(a)):
		Sum += a[i]
		if maxim < Sum:
			maxim = Sum
			r = i
			if maxim > total:
				break
		if Sum <= 0:
			l = i
			Sum = 0
	if l == 0 and r == n - 1:
		Sum = 0
		for ai in a:
			Sum += ai
			if maxim - Sum >= total:
				ans = 1
	elif maxim >= total:
		ans = 1
	if ans == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin
for _ in range(int(input())):
	n = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	s = 0
	m = l[0]
	b = 0
	count_ps = 0
	for i in range(1, n):
		if l[i] > 0:
			count_ps += 1
		m += l[i]
		s = max(l[i], s + l[i])
		b = max(s, b)
	s = 0
	for i in range(n - 1):
		s = max(l[i], s + l[i])
		b = max(s, b)
	if b >= m:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	for i in range(1, n):
		a[i] = a[i - 1] + a[i]
	for i in range(n - 1):
		if a[i] >= a[n - 1] or a[n - 1] - a[i] >= a[n - 1]:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def f(d, l, r):
	res = d[l]
	cur = 0
	for i in range(l, r):
		cur = max(0, cur + d[i])
		res = max(res, cur)
	return res
t = ii()
for _ in range(t):
	n = ii()
	d = li()
	print('YES') if sum(d) > max(f(d, 1, n), f(d, 0, n - 1)) else print('NO')


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	x = 'YES'
	s = sum(a)
	f = 0
	for i in range(n):
		if a[i] > 0:
			c += a[i]
			f += 1
		elif c + a[i] > 0:
			f += 1
			c += a[i]
		else:
			c = 0
			f = 0
		if c >= s and f != n:
			x = 'NO'
			break
		else:
			continue
	if f == n:
		c -= a[0]
		if s > c:
			x = 'YES'
	ans.append(x)
for i in range(t):
	print(ans[i])


n = int(input())
for i in range(n):
	m = int(input())
	l = list(map(int, input().split()))
	x = sum(l)
	a = x
	b = x
	k = 'y'
	j = 0
	while k == 'y' and j <= m - 2:
		a = a - l[j]
		b = b - l[m - 1 - j]
		if a >= x or b >= x:
			print('NO')
			k = 'n'
		j = j + 1
	if k == 'y':
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split()))
	ans = ['NO', 'YES']
	i = 0
	j = 0
	adel = ai[0]
	summ = 0
	while j < n:
		summ += ai[j]
		if i != 0 or j != n - 1:
			adel = max(adel, summ)
		if summ <= 0:
			i = j
			summ = 0
		j += 1
	i = n - 1
	summ = 0
	j = n - 1
	while j > -1:
		summ += ai[j]
		if j != 0 or i != n - 1:
			adel = max(adel, summ)
		if summ <= 0:
			i = j
			summ = 0
		j -= 1
	print(ans[sum(ai) > adel])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	val = 0
	totval = 0
	summ = 0
	flag = False
	summ = sum(a)
	start = -1
	end = -1
	for i in range(len(a)):
		val += a[i]
		if val <= a[i]:
			start = i
			val = a[i]
		if totval < val:
			end = i
			totval = val
		if totval >= summ and (not (start == 0 and end == n - 1)):
			flag = True
	if flag:
		NO()
	else:
		YES()


num_t = int(input())
for t in range(num_t):
	n = int(input())
	arr = [int(a) for a in input().strip().split()]
	pref_sum = 0
	ok = True
	for e in arr:
		pref_sum += e
		if pref_sum <= 0:
			ok = False
			break
	suf_sum = 0
	for e in arr[::-1]:
		suf_sum += e
		if suf_sum <= 0:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List

def solve(N, A):
	yasser = sum(A)
	presum = [0 for _ in range(N + 1)]
	for (i, v) in enumerate(A):
		presum[i + 1] = presum[i] + A[i]
	if any([presum[i] >= yasser for i in range(1, N)]) or any([v > yasser for v in A]):
		return 'NO'
	rightmax = [i for i in range(N + 1)]
	for i in range(N - 1, -1, -1):
		if presum[i] <= presum[rightmax[i + 1]]:
			rightmax[i] = rightmax[i + 1]
	for i in range(1, N + 1):
		j = rightmax[i]
		if j > i and j - i < N and (presum[j] - presum[i] >= yasser):
			return 'NO'
	return 'YES'

def test():
	N = random.randint(2, 10)
	A = [random.randint(-10, 10) for i in range(N)]
	print(N)
	print(A)
	print(sum(A))
	print(solve(N, A))
T = int(input())
ans = []
for ti in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	ans.append(solve(N, A))
print('\n'.join(ans))


q = int(input())
Ans = []
for i in range(q):
	ans = 'YES'
	n = int(input())
	A = list(map(int, input().split()))
	s = 0
	for i in range(n):
		s += A[i]
		if s <= 0:
			ans = 'NO'
			break
	s = 0
	for i in range(n - 1, -1, -1):
		s += A[i]
		if s <= 0:
			ans = 'NO'
			break
	Ans.append(ans)
for i in range(q):
	print(Ans[i])


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	(s, w, r) = (sum(b), 0, [])
	for i in b:
		w += i
		if w <= 0:
			a = -1
		r.append(w)
		if w >= s:
			break
	if max(r) >= s and (len(r) < len(b) or a == -1):
		print('NO')
	else:
		print('YES')


I = input
for _ in range(int(I())):
	try:
		n = int(I())
		a = list(map(int, I().split(' ')))
		s = 0
		t = 0
		tc = sum(a)
		c = 0
		for i in range(n):
			s += a[i]
			c += 1
			if t <= 0 and 0 < a[i] and (i != 0):
				s = a[i]
				c = 0
			t = s
			if s >= tc:
				if c != n:
					assert 1 == 0
				elif s - a[0] >= tc or s - a[n - 1] >= tc:
					assert 1 == 0
		print('YES')
	except AssertionError:
		print('NO')


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().strip().split()))
	flag = 1
	pref = 0
	for num in a:
		pref += num
		if pref <= 0:
			print('NO')
			flag = 0
			break
	if flag:
		suff = 0
		for num in a[::-1]:
			suff += num
			if suff <= 0:
				print('NO')
				flag = 0
				break
	if flag:
		print('YES')
		continue


from sys import stdin
from bisect import bisect_right
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	curr = 0
	ans = 0
	for i in range(n):
		if a[i] >= curr + a[i]:
			start = i
		curr = max(curr + a[i], a[i])
		if not (i == n - 1 and start == 0):
			ans = max(curr, ans)
	if ans >= sum(a):
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	c = 1
	ans = 0
	for i in range(n):
		s += a[i]
		if s <= 0:
			c = 0
			ans = 1
			break
	if c:
		ss = 0
		for i in range(n - 1, -1, -1):
			ss += a[i]
			if ss <= 0:
				ans = 1
				break
	if ans:
		print('NO')
	else:
		print('YES')


def solve(n, arr):
	if arr[0] < 0 or arr[-1] < 0 or arr[0] == 0 or (arr[-1] == 0):
		return 'NO'
	if min(arr) >= 0:
		return 'YES'
	s = sum(arr)
	(s1, s2) = (0, 0)
	for a in arr:
		if a >= 0:
			s1 += a
		if a < 0:
			s2 = s - a - s1
			if s1 >= s or s2 >= s:
				return 'NO'
			s1 += a
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = sum(a)
	(maxs, sumo, flag) = (0, 0, 0)
	for i in range(n - 1):
		sumo += a[i]
		maxs = max(maxs, sumo)
		if sumo < 0:
			sumo = 0
	sumo = 0
	for i in range(1, n):
		sumo += a[i]
		maxs = max(maxs, sumo)
		if sumo < 0:
			sumo = 0
	if maxs < ans:
		print('YES')
	else:
		print('NO')


def func(a):
	best = 0
	s = 0
	for i in range(n - 1):
		s = max(a[i], s + a[i])
		best = max(best, s)
	return best
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) > max(func(a[:-1]), func(a[1:])):
		print('YES')
	else:
		print('NO')


def solve(a, s, e):
	mcs = a[s]
	si = s
	ei = s
	cs = a[s]
	for i in range(s + 1, e + 1):
		if cs <= 0 and a[i] >= cs:
			si = i
			ei = i
			cs = a[i]
		else:
			ei += 1
			cs += a[i]
		if a[si] < 0 and si < ei:
			cs -= a[si]
			si += 1
		if cs > mcs:
			mcs = cs
	return mcs
t = int(input())
for zz in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a1 = solve(a, 0, n - 2)
	a2 = solve(a, 1, n - 1)
	if sum(a) > max(a1, a2):
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = sum(arr)
	m = 0
	dp = [0] * n
	dp[0] = arr[0]
	if dp[0] >= x:
		m = 1
	for i in range(1, n - 1):
		dp[i] = max(dp[i - 1] + arr[i], arr[i])
		if dp[i] >= x:
			m = 1
			break
	dp = [0] * n
	dp[1] = arr[1]
	if dp[1] >= x:
		m = 1
	for i in range(2, n):
		dp[i] = max(dp[i - 1] + arr[i], arr[i])
		if dp[i] >= x:
			m = 1
			break
	if m == 1:
		print('NO')
	else:
		print('YES')


def solve(n, a):
	x = 0
	for i in range(n - 1):
		x += a[i]
		if x <= 0:
			return 'NO'
	x = 0
	for i in range(n - 1, 0, -1):
		x += a[i]
		if x <= 0:
			return 'NO'
	return 'YES'

def main():
	t = int(input())
	anss = [''] * t
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		anss[i] = solve(n, a)
	for ans in anss:
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maxsum = 0
	minsum = 0
	yassersum = 0
	counter = 0
	flag = True
	finished = True
	between = False
	if arr[0] < 0:
		flag = False
		minsum = arr[0]
	for i in range(0, n):
		if flag:
			if counter + arr[i] > 0:
				counter += arr[i]
			else:
				counter = 0
				finished = False
		elif arr[i] >= 0:
			counter = arr[i]
			flag = True
		else:
			if arr[i] > minsum:
				minsum = arr[i]
			finished = False
		yassersum += arr[i]
		if finished:
			if i != n - 1:
				if counter > maxsum:
					maxsum = counter
					between = True
			elif counter > maxsum:
				maxsum = counter
				between = False
		elif counter > maxsum:
			maxsum = counter
	if flag:
		if maxsum > yassersum:
			print('NO')
		elif maxsum == yassersum:
			if between:
				print('NO')
			elif finished:
				print('YES')
			else:
				print('NO')
		else:
			print('YES')
	else:
		if maxsum == yassersum == 0:
			print('NO')
		if minsum >= yassersum:
			print('NO')
		else:
			print('YES')


def ch(a):
	s = 0
	for i in a:
		s += i
		if s <= 0:
			return False
	s = 0
	for i in a[::-1]:
		s += i
		if s <= 0:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if ch(a):
		print('YES')
	else:
		print('NO')


def check1(a):
	sum = 0
	for i in range(0, len(a) - 1):
		sum = sum + a[i]
		if sum <= 0:
			return 'NO'
	sum = 0
	for i in range(0, len(a) - 1):
		sum = sum + a[len(a) - 1 - i]
		if sum <= 0:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	print(check1(a))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans1 = a[0]
	su1 = 0
	for i in range(n - 1):
		su1 += a[i]
		ans1 = max(ans1, su1)
		su1 = max(su1, 0)
	ans2 = a[0]
	su2 = 0
	for i in range(1, n):
		su2 += a[i]
		ans2 = max(ans2, su2)
		su2 = max(su2, 0)
	if sum(a) > max(ans1, ans2):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	L2 = [0] * n
	L3 = [0] * n
	L2[0] = L[0]
	for i in range(1, n):
		L2[i] = L2[i - 1] + L[i]
	L3[n - 1] = L[n - 1]
	for i in range(2, n + 1):
		L3[n - i] = L3[n - i + 1] + L[n - i]
	if max(L2) == L2[n - 1] and max(L3) == L3[0] and (L3.count(L3[0]) == 1) and (L2.count(L2[n - 1]) == 1):
		print('YES')
	else:
		print('NO')


from collections import deque

def mSumLen(A, K):
	d = deque([[0, 0]])
	(res, cur) = (float('inf'), 0)
	for (i, a) in enumerate(A):
		cur += a
		while d and cur - d[0][1] >= K:
			res = min(res, i + 1 - d.popleft()[0])
		while d and cur <= d[-1][1]:
			d.pop()
		d.append([i + 1, cur])
	return res if res < float('inf') else 10 ** 9
for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	lar_size = mSumLen(arr, sum(arr))
	if lar_size >= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	k = 0
	f = True
	for i in range(n - 1):
		k = k + l[i]
		if k <= 0 or k >= s:
			f = False
			print('NO')
			break
	if f:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = sum(a)
	if n == 1:
		print('YES')
	else:
		f = 0
		p = 0
		for j in range(n):
			if f + a[j] <= 0:
				f = 0
				p = 0
			else:
				f += a[j]
				p += 1
			if f >= k:
				if p == n:
					if a[0] <= 0 or a[-1] <= 0:
						print('NO')
					else:
						print('YES')
				else:
					print('NO')
				break
		else:
			print('YES')


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	ss = [0]
	e = 1
	s = 0
	for i in range(0, n):
		s += a[i]
		ss.append(s)
	m = ss[n]
	k = n
	if m - ss[n - 1] >= ss[n]:
		e = 0
	else:
		for i in range(n - 2, -1, -1):
			m = max(m, ss[i + 1])
			if ss[i + 1] == m:
				k = i + 1
			if m - ss[i] >= ss[n] and (i != 0 or k != n):
				e = 0
				break
	if e == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(s1, s2) = (0, 0)
	for i in range(n):
		s1 += a[i]
		if s1 <= 0:
			break
		if s1 > s2 and i < n - 1:
			s2 = s1
	if s1 > 0 and s1 - s2 > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ans = 'YES'
	s = 0
	for i in range(n - 1):
		s += A[i]
		if s <= 0:
			ans = 'NO'
	s = 0
	for i in range(n - 1):
		s += A[-i - 1]
		if s <= 0:
			ans = 'NO'
	print(ans)


import collections
local = False
if local:
	file = open('B.txt', 'r')

def readInput():
	if local:
		return file.readline()
	else:
		return input()

def cakes(n, a):
	yasser = sum(a)
	start = 0
	for i in range(n - 1):
		start += a[i]
		if start >= yasser:
			return 'NO'
		if start < 0:
			start = 0
	start = 0
	for i in range(1, n):
		start += a[i]
		if start >= yasser:
			return 'NO'
		if start < 0:
			start = 0
	return 'YES'
t = int(readInput())
for i in range(t):
	n = int(readInput())
	a_line = readInput().split()
	a = [int(x) for x in a_line]
	print(cakes(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	tot = sum(a)
	cur = 0
	are = False
	for i in range(1, n + 1):
		cur = cur + a[-i]
		if cur <= 0:
			are = True
	cur = 0
	for i in range(n):
		cur += a[i]
		if cur <= 0:
			are = True
	if are:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag1 = 0
	for j in a:
		if j >= 0:
			flag1 = 1
			break
	if flag1 == 0:
		print('NO')
	else:
		if n == 2:
			if a[0] <= 0 or a[1] <= 0:
				print('NO')
			else:
				print('YES')
			continue
		sum_y1 = 0
		total_sum = 0
		for j in range(0, n - 1):
			sum_y1 += a[j]
			total_sum += a[j]
		total_sum += a[n - 1]
		max_so_far1 = -1
		max_ending_here1 = 0
		for j in range(n - 1):
			max_ending_here1 += a[j]
			if max_ending_here1 < 0:
				max_ending_here1 = 0
			if max_ending_here1 > max_so_far1:
				max_so_far1 = max_ending_here1
		sum_y2 = 0
		for j in range(1, n):
			sum_y2 += a[j]
		max_so_far2 = -1
		max_ending_here2 = 0
		for j in range(1, n):
			max_ending_here2 += a[j]
			if max_ending_here2 < 0:
				max_ending_here2 = 0
			if max_ending_here2 > max_so_far2:
				max_so_far2 = max_ending_here2
		if max(max_so_far1, max_so_far2) < total_sum:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	yas = sum(a)
	v = []
	p = 0
	for i in range(n):
		if a[i] < 0:
			count += 1
	if count > 0:
		if n == 2:
			if a[0] >= yas:
				print('NO')
			elif a[1] >= yas:
				print('NO')
			else:
				print('YES')
		elif a[0] < 0 or a[n - 1] < 0:
			print('NO')
		else:
			max_so_far = 0
			max_ending_here = 0
			for i in range(n):
				max_ending_here += a[i]
				if max_ending_here <= 0:
					max_ending_here = 0
					v.append(max_ending_here)
				if max_ending_here >= max_so_far:
					max_so_far = max_ending_here
					v.append(max_so_far)
			v.pop()
			count = 0
			for i in range(len(v)):
				if v[i] == 0:
					count += 1
			if max_so_far < yas:
				print('YES')
			elif yas == max_so_far:
				if max(v) < yas and count == 0:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
	elif a[0] == 0 or a[n - 1] == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	k = sum(li)
	dp = [0] * n
	(f, a) = (0, True)
	for i in range(n):
		f += li[i]
		if f <= 0:
			f = 0
			dp[i] = 0
			a = False
		else:
			dp[i] = f
	ma = max(dp)
	if a and ma == k:
		dp.pop()
		ma = max(dp)
	if ma < k:
		print('YES')
	else:
		print('NO')


test = int(input())
for i in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	max_till_now = 0
	max_so_far = 0
	summ = 0
	start = 0
	end = 0
	s = 0
	for i in range(n):
		max_so_far = max_so_far + arr[i]
		summ += arr[i]
		if max_till_now < max_so_far:
			max_till_now = max_so_far
			start = s
			end = i
		if max_so_far <= 0:
			max_so_far = 0
			s = i + 1
	max_len = end - start + 1
	if summ == max_till_now:
		if max_len == n:
			print('YES')
		else:
			print('NO')
	elif summ > max_till_now:
		print('YES')
	else:
		print('NO')


def max_subarray(nums):
	curr_sum = nums[0]
	max_sum = nums[0]
	for i in range(1, len(nums)):
		curr_sum = max(nums[i], curr_sum + nums[i])
		if curr_sum > max_sum:
			max_sum = curr_sum
	return max_sum
n = input('')
n = int(n)
output = []
for i in range(n):
	new_n = input('')
	cc = input('')
	cc = cc.split(' ')
	cc_int = list(map(int, cc))
	output.append(cc_int)
for i in output:
	yasser = sum(i)
	adel1 = max_subarray(i[1:])
	adel2 = max_subarray(i[:-1])
	if yasser > adel1 and yasser > adel2:
		print('YES')
	else:
		print('NO')


t = int(input())
answers = []
for j in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	summa = 0
	max_summa = 0
	for i in range(1, len(arr)):
		summa += arr[i]
		if summa < 0:
			summa = 0
		max_summa = max(summa, max_summa)
	summa = 0
	for i in range(len(arr) - 1):
		summa += arr[i]
		if summa < 0:
			summa = 0
		max_summa = max(summa, max_summa)
	if max_summa < sum(arr):
		answers.append('YES')
	else:
		answers.append('NO')
for i in range(len(answers)):
	print(answers[i])


from math import inf

def lis(arr):
	val = [0] * (len(arr) + 1)
	for i in range(len(arr)):
		val[i + 1] = max(val[i] + arr[i], arr[i])
	maxi = -inf
	i0 = -1
	for i in range(1, n + 1):
		if val[i] > maxi:
			i0 = i
			maxi = val[i]
	return [maxi, i0]
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x = lis(arr)
	if x[0] == sum(arr):
		sums = 0
		flag1 = 1
		for i in range(n - 1):
			sums += arr[i]
			if sums == x[0]:
				print('NO')
				flag1 = 0
				break
		if flag1:
			sums = 0
			flag = 1
			for i in range(n - 1, 0, -1):
				sums += arr[i]
				if sums == x[0]:
					print('NO')
					flag = 0
					break
			if flag:
				print('YES')
	else:
		print('NO')


def check(a):
	sum = 0
	for i in a:
		sum += i
		if sum <= 0:
			return False
	sum = 0
	for i in reversed(a):
		sum += i
		if sum <= 0:
			return False
	return True
t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(lambda x: int(x), input().split()))
	if check(a):
		print('YES')
	else:
		print('NO')


def maxSegment(v, a, b):
	mx = curr = s = 0
	l = r = -1
	for i in range(a, b):
		curr = curr + v[i]
		if curr > mx:
			mx = curr
			l = s
			r = i
		elif curr < 0:
			curr = 0
			s = i + 1
	return (mx, l, r)
t = int(input())
for case in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	sum = 0
	for x in v:
		sum = sum + x
	mx = maxSegment(v, 0, n - 1)
	temp = maxSegment(v, 1, n)
	mx = temp if temp[0] > mx[0] else mx
	if sum > mx[0]:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	ss = 0
	r = True
	for i in range(n - 1):
		ss = ss + a[i]
		if ss <= 0 or ss >= s:
			print('NO')
			r = False
			break
	if r:
		print('YES')


from sys import stdin
input = stdin.readline

def eat(arr):
	s = 0
	for i in arr:
		s += i
		if s <= 0:
			return 'NO'
	s = 0
	for i in reversed(arr):
		s += i
		if s <= 0:
			return 'NO'
	return 'YES'
for test in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(eat(lst))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(kk) for kk in input().split()]
	s = 0
	f = 0
	x = 0
	y = sum(a)
	for i in range(len(a) - 1):
		s += a[i]
		x = y - s
		if s <= 0 or x <= 0:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
import math
t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split(' ')))
	y = sum(l1)
	l = [0] * n
	l[0] = l1[0]
	for j in range(1, n):
		l[j] = l[j - 1] + l1[j]
	flag = True
	m1 = 1000000000
	for j in range(n):
		if j == 0:
			if l[j] >= y:
				flag = False
				break
			m1 = min(m1, l[j])
		else:
			if l[j] >= y and j != n - 1:
				flag = False
				break
			elif l[j] - m1 >= y:
				flag = False
				break
			m1 = min(m1, l[j])
	if flag == True:
		print('YES')
	else:
		print('NO')


from math import ceil

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	s = sum(a)
	s1 = 0
	f = 0
	f1 = 0
	for i in range(n):
		if s1 + a[i] <= a[i]:
			f1 = 1
			s1 = a[i]
		else:
			s1 += a[i]
		if s1 >= s:
			f = 1
			break
	s1 = 0
	for j in range(n - 1, -1, -1):
		if s1 + a[j] <= a[j]:
			f1 = 1
			s1 = a[j]
		else:
			s1 += a[j]
		if s1 >= s:
			f = 1
			break
	if f == 1:
		if i == n - 1 and j == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


import sys
from collections import Counter

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
sys.setrecursionlimit(20000)
T = int(input())
for _ in range(T):
	n = int(input())
	A = get_ints()
	adel_max = 0
	adel_current_max = 0
	for i in range(1, n):
		adel_current_max += A[i]
		if adel_current_max > adel_max:
			adel_max = adel_current_max
		elif adel_current_max < 0:
			adel_current_max = 0
	adel_current_max = 0
	for i in range(0, n - 1):
		adel_current_max += A[i]
		if adel_current_max > adel_max:
			adel_max = adel_current_max
		elif adel_current_max < 0:
			adel_current_max = 0
	if adel_max >= sum(A):
		print('NO')
	else:
		print('YES')


from itertools import accumulate
import sys
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = a[::-1]
	pre = list(accumulate(a))
	for i in pre:
		if i <= 0:
			print('NO')
			break
	else:
		suf = list(accumulate(b))
		for i in suf:
			if i <= 0:
				print('NO')
				break
		else:
			print('YES')


def mssl(l):
	best = cur = 0
	for i in l:
		cur = max(cur + i, 0)
		best = max(best, cur)
	return best

def cake():
	for _ in range(t):
		n = int(input())
		(*a,) = [int(x) for x in input().split()]
		(sum1, best1, best2) = (sum(a), mssl(a[1:]), mssl(a[:-1]))
		if sum1 > best1 and sum1 > best2:
			yield 'YES'
		else:
			yield 'NO'
t = int(input())
ans = cake()
print(*ans, sep='\n')


from itertools import accumulate
for t in range(int(input())):
	input()
	a = [int(i) for i in input().split()]
	s = sum(a)
	print('YES' if all((0 < i < s for i in list(accumulate(a))[:-1])) else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = 0
	s = 0
	ch = 1
	for i in range(n):
		p += a[i]
		if p <= 0:
			ch = 0
			break
	if ch == 1:
		for i in range(n - 1, -1, -1):
			s += a[i]
			if s <= 0:
				ch = 0
				break
	if ch == 0:
		print('NO')
	else:
		print('YES')


k = int(input())
while k > 0:
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	(m, h) = (0, 0)
	mx = -1e+18
	for i in range(n):
		if m <= 0 and i != 0:
			m = a[i]
			h = 1
		else:
			m += a[i]
		if i != n - 1 or h == 1:
			mx = max(mx, m)
	if mx >= s:
		print('NO')
	else:
		print('YES')
	k -= 1


def solve(arr, n):
	su = 0
	for i in range(len(arr)):
		su += arr[i]
		if su <= 0:
			return 'NO'
	su = 0
	for i in range(len(arr) - 1, -1, -1):
		su += arr[i]
		if su <= 0:
			return 'NO'
	return 'YES'
tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr, n))


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	s = 0
	j = 0
	maxi = -9999999999999999999999999
	p = 0
	q = 0
	z = 0
	for i in range(n):
		s += a[i]
		maxi = max(maxi, s)
		if s < 0:
			s = 0
			p = i
	if i - p == n - 1:
		mini1 = mini2 = 9999999999999999999999999
		s = 0
		for i in range(n):
			s += a[i]
			mini1 = min(mini1, s)
		s = 0
		for i in range(n - 1, -1, -1):
			s += a[i]
			mini2 = min(mini2, s)
		maxi -= min(mini1, mini2)
	print('YES' if sum(a) > maxi else 'NO')


for i in ' ' * int(input()):
	n = int(input())
	L = list(map(int, input().split()))
	M = [0]
	for j in range(n):
		M.append(M[-1] + L[j])
	mi = min(M)
	ma = max(M)
	state = False
	for i in range(n + 1):
		if i != 0:
			if M[i] <= mi:
				state = True
		if i != n:
			if M[i] >= ma:
				state = True
	print(['YES', 'NO'][state])


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	yass = sum(l)
	maxval = maxfar = 0
	bfore = 0
	after = 0
	s = 0
	for i in range(n):
		maxval += l[i]
		if maxval > maxfar:
			maxfar = maxval
			bfore = s
			after = i
		if maxval < 0:
			s += 1
			maxval = 0
	if after - bfore == n - 1:
		maxval = maxfar = 0
		bfore = after = s = 1
		for i in range(1, n):
			maxval += l[i]
			if maxval > maxfar:
				maxfar = maxval
				bfore = s
				after = i
			if maxval < 0:
				s += 1
				maxval = 0
	if maxfar < yass:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	inp = [int(x) for x in input().split()]
	s = 0
	happy = True
	for x in inp:
		s += x
		if s <= 0:
			happy = False
			break
	s = 0
	if happy:
		for x in reversed(inp):
			s += x
			if s <= 0:
				happy = False
				break
	if happy:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	c = 1
	s1 = 0
	s2 = 0
	for i in range(0, n):
		s1 += A[i]
		s2 += A[n - i - 1]
		if s1 <= 0 or s2 <= 0:
			c = 0
			break
	if c:
		print('YES')
	else:
		print('NO')


def solve(lst):
	total = 0
	for num in lst:
		total += num
		if total <= 0:
			return True
	total = 0
	for num in reversed(lst):
		total += num
		if total <= 0:
			return True
	return False
n = int(input())
for _ in range(n):
	m = input()
	lst = list(map(int, input().split()))
	if solve(lst):
		print('NO')
	else:
		print('YES')


t = int(input())
for j in range(t):
	(n, s) = (int(input()), input().split())
	(a, b, c, p) = (0, 0, 0, 0)
	for i in range(n):
		a = a + int(s[i])
		if a <= b:
			p = 1
	a = 0
	for i in range(n - 1, -1, -1):
		a = a + int(s[i])
		if a <= c:
			p = 1
	if p == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cn = 0
	for i in arr:
		if i == 0:
			cn += 1
	if cn == n:
		print('NO')
		continue
	s = sum(arr)
	pre = [arr[0]]
	for i in range(1, n):
		pre.append(arr[i] + pre[i - 1])
	suf = [arr[n - 1]]
	for j in range(n - 2, -1, -1):
		suf.append(suf[n - 1 - j - 1] + arr[j])
	suf = suf[::-1]
	ind = []
	for i in range(n):
		if arr[i] < 0:
			ind.append(i)
	if len(ind) == 0:
		print('YES')
		continue
	chk = 0
	for i in ind:
		if i == 0:
			print('NO')
			chk = 1
			break
		elif i == n - 1:
			print('NO')
			chk = 1
			break
		elif pre[i - 1] >= s or suf[i + 1] >= s:
			print('NO')
			chk = 1
			break
	else:
		print('YES')


def testcase():
	n = int(input())
	taste = [int(i) for i in input().split()]
	y = sum(taste)
	s = 0
	current_max = 0
	for i in range(len(taste) - 1):
		current_max += taste[i]
		if current_max < 0:
			current_max = 0
		if s < current_max:
			s = current_max
	current_max = 0
	for i in range(1, len(taste)):
		current_max += taste[i]
		if current_max < 0:
			current_max = 0
		if s < current_max:
			s = current_max
	if y > s:
		print('YES')
	else:
		print('NO')
t = int(input())
for test in range(t):
	testcase()


t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	(s, smax) = (0, 0)
	for i in range(n):
		s += x[i]
		if s <= 0:
			break
		if s > smax and i < n - 1:
			smax = s
	if s > 0 and s - smax > 0:
		print('YES')
	else:
		print('NO')


def get_max_subsum(a, left, right):
	max_subsum = 0
	cur_subsum = 0
	for i in range(left, right):
		cur_subsum = max(0, cur_subsum + a[i])
		max_subsum = max(max_subsum, cur_subsum)
	return max_subsum
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split(' ')))
	max_subsum1 = get_max_subsum(a, 0, len(a) - 1)
	max_subsum2 = get_max_subsum(a, 1, len(a))
	max_subsum = max(max_subsum1, max_subsum2)
	if sum(a) > max_subsum:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(n):
	input()
	b = [int(a) for a in input().strip().split()]
	cs = 0
	printed = False
	for i in range(len(b)):
		cs += b[i]
		if cs <= 0:
			print('NO')
			printed = True
			break
	cs = 0
	if printed:
		continue
	for i in range(len(b) - 1, 0, -1):
		cs += b[i]
		if cs <= 0:
			print('NO')
			printed = True
			break
	if not printed:
		print('YES')


import sys
queries = int(sys.stdin.readline())

def findAnswer():
	count = int(sys.stdin.readline())
	array = sys.stdin.readline().strip().split()
	array = [int(num) for num in array]
	arrayPacked = []
	yasser = 0
	cakes = count
	position = count - 1
	if array[0] <= 0:
		return 'NO'
	while position >= 0:
		yasser += array[position]
		if yasser <= 0:
			return 'NO'
		position -= 1
	yasser = 0
	position = 0
	while position < count:
		yasser += array[position]
		if yasser <= 0:
			return 'NO'
		position += 1
	return 'YES'
	tmpSum = 0
	for taste in array:
		if tmpSum + taste < tmpSum and tmpSum > 0:
			arrayPacked.append(tmpSum)
			tmpSum = taste
		elif tmpSum + taste > tmpSum and tmpSum < 0:
			arrayPacked.append(tmpSum)
			tmpSum = taste
		else:
			tmpSum += taste
	arrayPacked.append(tmpSum)
	count = len(arrayPacked)
	for left in range(count):
		tmpSum = 0
		for pos in range(left, count if left > 0 else count - 1):
			tmpSum += arrayPacked[pos]
			if tmpSum >= yasser:
				return 'NO'
	if count == 1 and arrayPacked[0] < 0:
		return 'NO'
	return 'YES'
for query in range(queries):
	print(findAnswer())


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	cumsum = 0
	for j in range(n - 1):
		cumsum += a[j]
		if cumsum <= 0:
			flag = False
			break
	cumsum = 0
	for j in range(n - 1, 0, -1):
		cumsum += a[j]
		if cumsum <= 0:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	s1 = sum(a)
	curr_sum = 0
	flag = 0
	maxi = float('-inf')
	pos = 0
	for (i, x) in enumerate(a):
		curr_sum += x
		if curr_sum >= s1 and (not (i == n - 1 and pos == 0)):
			flag = 1
			break
		if curr_sum <= 0:
			pos = i + 1
	if flag:
		print('NO')
	else:
		print('YES')


def ma(a, size):
	max_so_far = -10 ** 9
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = ma(a[1:], len(a) - 1)
	j = ma(a[:n - 1], len(a) - 1)
	if sum(a) > max(j, k):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	yas = sum(a)
	(cur_max, ade) = (0, float('-inf'))
	for i in range(1, n):
		cur_max += a[i]
		if cur_max < 0:
			cur_max = 0
		ade = max(ade, cur_max)
	cur_max = 0
	for i in range(n - 1):
		cur_max += a[i]
		if cur_max < 0:
			cur_max = 0
		ade = max(ade, cur_max)
	print('YES' if yas > ade else 'NO')


def solve(n, cupcakes):
	total_tastiness = sum(cupcakes)
	max_so_far = -int(1000000000.0) - 1
	max_ending_here = 0
	start = 0
	for i in range(n):
		max_ending_here = max_ending_here + cupcakes[i]
		if max_so_far < max_ending_here and (not (start == 0 and i == n - 1)):
			max_so_far = max_ending_here
			if max_so_far >= total_tastiness:
				print('NO')
				return
		if max_ending_here <= 0:
			start = i + 1
			max_ending_here = 0
	max_segment_tastiness = max_so_far
	print('YES')

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		cupcakes = [int(x) for x in input().split(' ')]
		solve(n, cupcakes)
main()


t = int(input())
for o in range(t):
	n = int(input())
	mas = list(map(int, input().split()))
	p = 0
	f = True
	for i in range(n - 1):
		p += mas[i]
		if p <= 0:
			f = False
			break
	p = 0
	for i in range(n - 1, 0, -1):
		p += mas[i]
		if p <= 0:
			f = False
			break
	if f == True:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))

	def check(a):
		s = 0
		for i in a:
			s += i
			if s <= 0:
				return False
		s = 0
		for i in a[::-1]:
			s += i
			if s <= 0:
				return False
		return True
	if check(a):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	ans = 0
	s = 0
	for r in a[:-1]:
		s += r
		ans = max(ans, s)
	s = 0
	for r in a[1:]:
		s += r
		ans = max(ans, s)
		if s <= 0:
			s = 0
	if y > ans:
		print('YES')
	else:
		print('NO')
	t -= 1


def max_subarry(nums):
	m = nums[0]
	tem_m = nums[0]
	pre = nums[0]
	global resres
	for i in range(1, len(nums)):
		if nums[i] <= 0:
			resres = 123
		if pre <= 0:
			tem_m = nums[i]
			pre = nums[i]
		else:
			pre += nums[i]
			tem_m += nums[i]
		if tem_m > m:
			m = tem_m
	return m
resres = 0
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	res = sum(s)
	resMax = max_subarry(s)
	if res == resMax:
		s1 = s[:]
		s2 = s[:]
		s1.pop(-1)
		s2.pop(0)
		res1 = max_subarry(s1)
		res2 = max_subarry(s2)
		res3 = max(res1, res2)
		if res <= res3:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def maxSubArraySum(a, size):
	max_so_far = -100000 - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	sum1 = sum(a)
	b = a[:]
	a.pop(0)
	b.pop(n - 1)
	sum2 = max(maxSubArraySum(a, n - 1), maxSubArraySum(b, n - 1))
	if sum2 < sum1:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	n = ii()
	a = li()
	t = 0
	for i in range(n):
		t += a[i]
		if t <= 0:
			break
	s = 0
	for i in range(n):
		s += a[-i - 1]
		if s <= 0:
			break
	if t <= 0 or s <= 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	yasser = arr[0]
	(g_sum, c_sum) = (arr[0], arr[0])
	(g_sum2, c_sum2) = (arr[1], arr[1])
	for i in range(1, len(arr)):
		if i < len(arr) - 1:
			c_sum = max(arr[i], c_sum + arr[i])
			g_sum = max(g_sum, c_sum)
		if i >= 2:
			c_sum2 = max(arr[i], c_sum2 + arr[i])
			g_sum2 = max(g_sum2, c_sum2)
		yasser += arr[i]
	adel = max(g_sum, g_sum2)
	if yasser > adel:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	s = 0
	for i in range(0, n - 1):
		s += l[i]
		if s <= 0:
			print('NO')
			c = 1
			break
	if c == 1:
		continue
	s = 0
	for i in range(n - 1, 0, -1):
		s += l[i]
		if s <= 0:
			print('NO')
			c = 1
			break
	if c == 1:
		continue
	print('YES')


def kadane(arr):
	curr_max = arr[0]
	overall_max = arr[0]
	for j in range(1, len(arr)):
		curr_max = max(arr[j], curr_max + arr[j])
		overall_max = max(curr_max, overall_max)
	return overall_max
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	total = sum(l)
	if total > kadane(l[:n - 1]) and total > kadane(l[1:n]):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	bad = False
	curr = 0
	for i in L:
		curr += i
		if curr <= 0:
			bad = True
			break
	L.reverse()
	curr = 0
	for i in L:
		curr += i
		if curr <= 0:
			bad = True
			break
	if bad:
		print('NO')
	else:
		print('YES')


def happiness(L):
	n = len(L)
	v = 0
	u = 0
	for i in range(0, n):
		v += L[i]
		if v <= 0:
			return 'NO'
	for i in range(n - 1, -1, -1):
		u += L[i]
		if u <= 0:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	print(happiness(L))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	d = a[0]
	ans = True
	i = 1
	while i < n and d > 0:
		d += a[i]
		i += 1
	if i < n:
		ans = False
	d = a[-1]
	i = n - 2
	while i > -1 and d > 0:
		d += a[i]
		i -= 1
	if i > -1:
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.buffer.readline
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	now = 0
	ssm = 0
	flag = 0
	for x in a[:-1]:
		ssm += x
		if ssm - now >= sm:
			flag = 1
			break
		now = min(now, ssm)
	now = 0
	ssm = 0
	for x in a[1:]:
		ssm += x
		if ssm - now >= sm:
			flag = 1
			break
		now = min(now, ssm)
	if flag:
		print('NO')
	else:
		print('YES')
	t -= 1


from sys import stdin
input = stdin.readline

def getAns(n, a):
	b = [a[0]] + [0] * (n - 1)
	if b[0] < 0:
		b[0] = 0
	for i in range(1, n):
		b[i] = a[i] + b[i - 1]
		if b[i] < 0:
			b[i] = 0
	if sum(a) > max(b) or (b.index(max(b)) == n - 1 and 0 not in b):
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	getAns(n, a)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	(v1, v2) = ([], [])
	p1 = p2 = 0
	a = list(map(int, input().split()))
	for i in range(n - 1):
		p1 += a[i]
		p2 += a[-i - 1]
		v1 += (p1,)
		v2 += (p2,)
	print('YES' if sum(a) > max(max(v1), max(v2)) else 'NO')


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	l = 0
	r = n - 1
	ls = 0
	rs = 0
	ans = 'YES'
	for __ in range(n - 1):
		ls += a[l]
		rs += a[r]
		l += 1
		r -= 1
		if ls <= 0 or rs <= 0:
			ans = 'NO'
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	a = b = 0
	r = 'YES'
	for i in range(n - 1):
		a += A[i]
		b += A[n - i - 1]
		if a < 1 or b < 1:
			r = 'NO'
			break
	print(r)


for _ in range(int(input())):
	i1 = int(input())
	ar = list(map(int, input().split()))
	ts = sum(ar)
	s1 = 0
	s2 = 0
	flag = True
	for i in range(i1 - 1):
		s1 += ar[i]
		s2 += ar[-(i + 1)]
		if s1 >= ts or s2 >= ts:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for q in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	sumN = 0
	for i in range(n):
		sumN += a[i]
	ans1 = a[1]
	adele = 0
	minS = 0
	for i in range(1, n):
		adele += a[i]
		ans1 = max(ans1, adele - minS)
		minS = min(minS, adele)
	ans2 = a[0]
	ad2 = 0
	minS2 = 0
	for i in range(n - 1):
		ad2 += a[i]
		ans2 = max(ans2, ad2 - minS2)
		minS2 = min(minS2, ad2)
	ans = max(ans1, ans2)
	if ans < sumN:
		print('YES')
	else:
		print('NO')


for nt in range(int(input())):
	n = int(input())
	new = list(map(int, input().split()))
	s = sum(new)
	count = 0
	start = -1
	for i in range(len(new)):
		if new[i] >= 0:
			start = i
			break
	if start == -1:
		print('NO')
		continue
	if start != 0:
		flag1 = 1
	else:
		flag1 = 0
	flag = 0
	for i in range(start, n):
		if count + new[i] > 0:
			count += new[i]
		else:
			count = 0
			flag1 = 1
		if count >= s and (flag1 == 1 or i != n - 1):
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


def solve(a, first, last):
	max_so_far = 0
	meh = 0
	for i in range(first, last):
		meh = meh + a[i]
		if max_so_far < meh:
			max_so_far = meh
		if meh < 0:
			meh = 0
	return max_so_far
for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if solve(arr, 1, n) < sum(arr) and solve(arr, 0, n - 1) < sum(arr):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	s = 0
	f = 0
	for i in range(n):
		m = max(m, l[i])
		s = s + l[i]
		if l[i] < 0:
			f = 1
	if m > s:
		print('NO')
	else:
		x = 0
		y = 0
		r = 0
		for i in range(n - 1):
			if l[i] > 0:
				x = x + l[i]
			else:
				y = y + l[i]
			if x + y <= 0:
				x = 0
				y = 0
			if x + y >= s:
				r = 1
		x = 0
		y = 0
		for i in range(1, n):
			if l[i] > 0:
				x = x + l[i]
			else:
				y = y + l[i]
			if x + y <= 0:
				x = 0
				y = 0
			if x + y >= s:
				r = 1
		if r == 1:
			print('NO')
		else:
			print('YES')


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
for _ in range(iinput()):
	n = iinput()
	a = rlinput()
	dp = [a[i] for i in range(n)]
	start = [0 for i in range(n)]
	mx = dp[0]
	for i in range(1, n):
		if dp[i - 1] + a[i] > a[i]:
			dp[i] = dp[i - 1] + a[i]
			start[i] = start[i - 1]
		else:
			start[i] = i
	mx = max(dp)
	end = dp.index(mx)
	start = start[end]
	if start == 0 and end == n - 1:
		dp.remove(mx)
		if max(dp) < sum(a):
			print('YES')
		else:
			print('YES')
	elif mx < sum(a):
		print('YES')
	else:
		print('NO')


def maxSubArraySum(a, size, initial):
	max_so_far = a[initial]
	curr_max = a[initial]
	for i in range(initial + 1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	yasser = 0
	for i in range(0, n):
		yasser += arr[i]
	sum1 = maxSubArraySum(arr, n - 1, 0)
	sum2 = maxSubArraySum(arr, n, 1)
	if sum1 > sum2:
		adel = sum1
	else:
		adel = sum2
	if yasser > adel:
		print('YES')
	else:
		print('NO')
	t = t - 1


from math import ceil
from math import factorial
from collections import *
from operator import itemgetter
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
t = ii()
for _ in range(t):
	n = ii()
	a = iia()
	x = [0] * n
	y = [0] * n
	x[0] = max(a[0], 0)
	for i in range(1, n - 1):
		x[i] = max(a[i], x[i - 1] + a[i], 0)
	y[1] = max(a[1], 0)
	for i in range(2, n):
		y[i] = max(a[i], y[i - 1] + a[i], 0)
	maxi = max(max(x), max(y))
	if maxi < sum(a):
		print('YES')
	else:
		print('NO')


from sys import stdin
r = stdin.readline

def kadane(a):
	(ans1, ans2, max_ending_here) = (float('-inf'), float('-inf'), 0)
	for i in range(1, len(a)):
		max_ending_here = max_ending_here + a[i]
		ans1 = max(ans1, max_ending_here)
		if max_ending_here < 0:
			max_ending_here = 0
	max_ending_here = 0
	for i in range(len(a) - 1):
		max_ending_here = max_ending_here + a[i]
		ans2 = max(ans2, max_ending_here)
		if max_ending_here < 0:
			max_ending_here = 0
	return max(ans1, ans2)

def solve(nums):
	n = len(nums)
	maxsum = kadane(nums)
	return sum(nums) > maxsum

def main():
	cases = int(r())
	for case in range(cases):
		n = int(r())
		nums = list(map(int, r().strip().split()))
		print('YES' if solve(nums) else 'NO')
main()


T = int(input())
for _ in range(T):
	n = int(input())
	c = list(map(int, input().split()))
	t1 = 0
	flag1 = 0
	flag2 = 0
	i = 0
	while i < n:
		t1 += c[i]
		if t1 <= 0:
			flag1 = 1
			break
		i += 1
	i = n - 1
	t1 = 0
	while i >= 0:
		t1 += c[i]
		if t1 <= 0:
			flag2 = 1
			break
		i -= 1
	if flag1 == 1 or flag2 == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
s = sum
l = len

def max_subarray(numbers):
	best_sum = float('-inf')
	best_start = best_end = 0
	current_sum = 0
	for (current_end, x) in enumerate(numbers):
		if current_sum <= 0:
			current_start = current_end
			current_sum = x
		else:
			current_sum += x
		if current_sum > best_sum:
			best_sum = current_sum
			best_start = current_start
			best_end = current_end + 1
	return (best_sum, best_start, best_end)
for i in range(t):
	lens = int(input())
	array = [int(i) for i in input().split(' ')]
	yasell = s(array)
	maxvalue = max_subarray(array)
	if maxvalue[1] == 0 and maxvalue[2] == lens:
		print('YES')
	elif yasell > maxvalue[0]:
		print('YES')
	else:
		print('NO')


def ok(a):
	s = sum(a)
	ss = 0
	for i in range(len(a) - 1):
		ss = ss + a[i]
		if ss <= 0 or ss >= s:
			return 'NO'
	return 'YES'
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(ok(a))


def solve(n, a):
	sum = 0
	for i in range(n):
		sum += a[i]
		if sum <= 0:
			return 0
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += a[i]
		if sum <= 0:
			return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = solve(n, a)
	if ans == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s1 = 0
	ss = []
	mins = []
	min_ids = []
	for el in a:
		s1 += el
		ss.append(s1)
		if len(mins) == 0:
			mins.append(el)
		else:
			mins.append(min(mins[-1], s1))
	s2_max = 0
	for j in range(len(ss)):
		if j == 0:
			s2 = ss[j]
		elif j == len(ss) - 1:
			s2 = ss[j] - mins[j - 1]
		else:
			s2 = max(ss[j], ss[j] - mins[j - 1])
		if s2_max < s2:
			s2_max = s2
	if s1 > s2_max:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	v = [int(i) for i in input().split()]
	ya = sum(v)
	a = 'YES'
	c = 0
	fl = 0
	for i in range(len(v)):
		if v[i] > 0:
			c += v[i]
		elif c + v[i] > 0:
			c += v[i]
		else:
			c = 0
			fl = 1
		if c >= ya and (fl and i == n - 1 or i < n - 1):
			a = 'NO'
			break
	print(a)


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
from statistics import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	n = ipn()
	a = ipl()
	pre = 0
	for i in range(n - 1):
		pre += a[i]
		if pre <= 0:
			print('NO')
			return
	suf = 0
	for i in range(n - 1, 0, -1):
		suf += a[i]
		if suf <= 0:
			print('NO')
			return
	print('YES')
t = ipn()
for _ in range(t):
	solve()


from math import gcd

def f(a):
	ans = [0, 0]
	cur = 0
	l = 0
	for i in a:
		cur += i
		if cur <= 0:
			l = 0
			cur = 0
		else:
			l += 1
		if ans[0] <= cur:
			if ans[0] != cur:
				ans[1] = l
			ans[0] = cur
	if ans[0] >= sum(a) and ans[1] < len(a):
		return 'NO'
	return 'YES'
for i in range(int(input())):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(f(lst))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	one = sum(a)
	for j in range(n - 1):
		a[j + 1] += a[j]
	ans = -10 ** 10
	ans2 = -10 ** 10
	mini = a[0]
	for j in range(1, n):
		p = a[j] - mini
		mini = min(mini, a[j])
		ans = max(ans, p)
	mini = 0
	for j in range(n - 1):
		p = a[j] - mini
		mini = min(mini, a[j])
		ans2 = max(ans2, p)
	ans = max(ans, ans2)
	if ans >= one:
		print('NO')
	else:
		print('YES')


T = int(input())
for i in range(T):
	N = int(input())
	s = 0
	m = 0
	sa = 0
	f = 0
	l = [int(x) for x in input().split()]
	sa = sum(l)
	if l[0] < 0 or l[N - 1] < 0:
		print('NO')
	else:
		for j in range(N - 1):
			s = s + l[j]
			if s >= sa:
				f = 1
				break
			if s < 0:
				s = 0
		for j in range(1, N):
			m = m + l[j]
			if m >= sa:
				f = 1
				break
			if m < 0:
				m = 0
		if f == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split(' ')]
	temp = 0
	cond = False
	for i in range(n - 1):
		temp += nums[i]
		if temp <= 0:
			print('NO')
			cond = True
			break
	if cond:
		continue
	temp = 0
	for i in range(n - 1, 0, -1):
		temp += nums[i]
		if temp <= 0:
			print('NO')
			cond = True
			break
	if cond:
		continue
	print('YES')


for _ in range(int(input())):
	n = int(input())
	c = 0
	s = 0
	z = 'YES'
	l = list(map(int, input().split()))
	s1 = sum(l)
	for i in range(len(l) - 1):
		s = s + l[i]
		c = c + l[-i - 1]
		if s >= s1:
			z = 'NO'
		if c >= s1:
			z = 'NO'
	print(z)


def find_max_subarray(alist, start, end):
	max_ending_at_i = max_seen_so_far = alist[start]
	max_left_at_i = max_left_so_far = start
	max_right_so_far = start + 1
	for i in range(start + 1, end):
		if max_ending_at_i > 0:
			max_ending_at_i += alist[i]
		else:
			max_ending_at_i = alist[i]
			max_left_at_i = i
		if max_ending_at_i > max_seen_so_far:
			max_seen_so_far = max_ending_at_i
			max_left_so_far = max_left_at_i
			max_right_so_far = i + 1
	return (max_left_so_far, max_right_so_far, max_seen_so_far)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	adl = []
	for i in range(1, 3):
		adl.append(find_max_subarray(a, i - 1, n - 2 + i))
	ad = max(adl[0][2], adl[1][2])
	if y > ad:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	sa = sum(a)
	ss = 0
	mx = 0
	l = r = 0
	for i in range(n):
		ss += a[i]
		if ss <= 0:
			ss = 0
			l = i + 1
		if ss > mx:
			mx = ss
			r = i
	if mx >= sa and (not (l == 0 and r == n - 1)):
		print('NO')
	else:
		print('YES')


def checker(n, lst):
	(c, c2, flag, k1) = (0, 0, 0, 0)
	if n != 1:
		for k in range(n):
			c2 += lst[k]
		for k in range(n):
			c += lst[k]
			k1 += 1
			if c >= c2:
				if k1 != n:
					flag = 1
					break
			if c <= 0:
				(c, k1) = (0, 0)
	else:
		return 'NO'
	return 'NO' if flag == 1 else 'YES'
for _ in range(int(input())):
	m = int(input())
	a = [int(i) for i in input().split()]
	print(checker(m, a))


import math
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	ps = [lst[0]]
	ss = [lst[n - 1]]
	for i in range(1, n):
		ps.append(lst[i] + ps[-1])
		ss.append(ss[-1] + lst[n - 1 - i])
	ans = 'YES'
	for i in range(n):
		if ps[i] <= 0 or ss[i] <= 0:
			ans = 'NO'
			break
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = 0
	b = 0
	c = 0
	f = 1
	for i in l:
		a += i
		b = max(b + i, 0)
		if b == 0:
			f = 0
		c = max(b, c)
	if a > c:
		print('YES')
	elif f == 1:
		if l[0] < l[-1]:
			l[0] = -1
		else:
			l[-1] = -1
		b = 0
		c = 0
		for i in l:
			b = max(b + i, 0)
			if b == 0:
				f = 0
			c = max(b, c)
		if a > c:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	N = int(input())
	A = [int(x) for x in input().split()]
	yasser = sum(A)
	rui = [0]
	for i in range(1, N):
		rui.append(rui[i - 1] + A[i])
		if rui[i] <= 0:
			rui[i] = 0
	rui2 = [0]
	for i in range(N - 1):
		rui2.append(rui2[i] + A[i])
		if rui2[i + 1] <= 0:
			rui2[i + 1] = 0
	adel = max(max(rui), max(rui2))
	if adel >= yasser:
		print('NO')
	else:
		print('YES')


def solve(a, n):
	yasser = sum(a)
	min_pr = 1
	max_pref = yasser
	flag = False
	curr_str = 0
	for i in range(len(a)):
		curr_str += a[i]
		if curr_str >= max_pref:
			max_pref = curr_str
			if i != len(a) - 1:
				flag = True
		if curr_str < min_pr:
			min_pr = curr_str
	if min_pr <= 0:
		adel = max_pref - min_pr
	elif flag:
		adel = max_pref
	else:
		return 'YES'
	if yasser > adel:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(solve(a, n))


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		n = nu()
		a = li()
		mx = -9999999999999999
		st = 0
		for i in range(n - 1):
			if st + a[i] < 0:
				st = 0
			else:
				st += a[i]
				mx = max(mx, st)
		st = 0
		for i in range(1, n):
			if st + a[i] < 0:
				st = 0
			else:
				st += a[i]
				mx = max(mx, st)
		if mx == -9999999999999999:
			mx = sorted(a)[n - 1]
		if mx < sum(a):
			print('YES')
		else:
			print('NO')
solve()


t = int(input())
lis = []
for _ in range(t):
	N = int(input())
	lis = list(map(int, input().split()))
	R = sum(lis) - lis[0]
	L = 0
	if lis[0] <= 0 or lis[-1] <= 0:
		print('NO')
		continue
	for i in range(1, N):
		L += lis[i - 1]
		R -= lis[i]
		if lis[i] <= 0:
			if L <= -lis[i] or R <= -lis[i]:
				print('NO')
				break
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	a = list(map(int, a))
	for i in range(1, n):
		a[i] += a[i - 1]
	k = s = 0
	for i in range(n):
		if i != n - 1:
			if a[i] - k > s:
				s = a[i] - k
		else:
			for j in range(n):
				if a[i] - a[j] > s:
					s = a[i] - a[j]
		if a[i] < k:
			k = a[i]
	if s >= a[n - 1]:
		print('NO')
	else:
		print('YES')


INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	a = I()
	yass = sum(a)
	ans = 'YES'
	cur = 0
	for i in range(n - 1):
		cur += a[i]
		if cur >= yass:
			ans = 'NO'
			break
		cur = max(cur, 0)
	cur = 0
	for i in range(1, n):
		cur += a[i]
		if cur >= yass:
			ans = 'NO'
			break
		cur = max(cur, 0)
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	m = sum(s)
	t = 'YES'
	(e, g) = (0, 0)
	for i in range(len(s) - 1):
		e += s[i]
		g += s[-i - 1]
		if e >= m:
			t = 'NO'
		if g >= m:
			t = 'NO'
	print(t)


for _ in range(int(input())):
	n = int(input())
	cake = list(map(int, input().split()))
	dp_1 = [cake[0]]
	dp_2 = [cake[1]]
	ans = 'NO'
	s = sum(cake)
	for i in range(1, n - 1):
		dp_1.append(max(cake[i], cake[i] + dp_1[i - 1]))
	for i in range(2, n):
		dp_2.append(max(cake[i], cake[i] + dp_2[i - 2]))
	if s > max(dp_1) and s > max(dp_2):
		ans = 'YES'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	yasser = sum(a)
	flag = 0
	s = 0
	for i in range(n - 1):
		s += a[i]
		if s >= yasser or s <= 0:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = [int(i) for i in input().split()[:n]]
	totsum = sum(a)
	max_so_far = -10 ** 20
	max_ending_here = 0
	for i in range(0, n - 1):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	max_ending_here = 0
	for i in range(1, n):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	maxsum = max_so_far
	print('YES' if totsum > maxsum else 'NO')
t = int(input())
for _ in range(t):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	now = 0
	for i in range(n - 1):
		now += a[i]
		if now <= 0:
			print('NO')
			break
	else:
		now = 0
		for i in range(n - 1, 0, -1):
			now += a[i]
			if now <= 0:
				print('NO')
				break
		else:
			print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	s1 = sum(li)
	k = 0
	res = True
	for i in range(n - 1):
		k = k + li[i]
		if k <= 0 or k >= s1:
			res = False
			print('NO')
			break
	if res:
		print('YES')


import math

def main_function():
	test_cases = range(int(input()))
	for test_case in test_cases:
		n = int(input())
		a = [int(i) for i in input().split(' ')]
		current_adel = 0
		hist = []
		is_cut = False
		for i in range(len(a)):
			current_adel += a[i]
			if current_adel <= 0:
				current_adel = 0
				is_cut = True
			hist.append(current_adel)
		yasser = sum(a)
		max_adel = max(hist)
		if yasser > max_adel:
			print('YES')
		elif max_adel < yasser:
			print('NO')
		elif is_cut:
			print('NO')
		else:
			hist.pop()
			if max_adel == max(hist):
				print('NO')
			else:
				print('YES')
main_function()


list_ans = []
for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = []
	list2.append(list1[0])
	for i in range(1, n):
		list2.append(list2[i - 1] + list1[i])
	b = list2[-1]
	for i in range(n - 1):
		if list2[i] <= 0 or list2[i] >= b:
			list_ans.append('NO')
			break
	else:
		list_ans.append('YES')
print(*list_ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ans = 'YES'
	st = 0
	for j in range(n - 1):
		st += A[j]
		if st <= 0:
			ans = 'NO'
	st = 0
	for j in range(n - 1):
		st += A[-j - 1]
		if st <= 0:
			ans = 'NO'
	print(ans)


t = int(input())
for tc in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	max_res = a[0]
	res = 0
	sum_all = 0
	for i in range(0, n - 1):
		res += a[i]
		max_res = max(max_res, res)
		sum_all += a[i]
		if res < 0:
			res = 0
	sum_all += a[n - 1]
	res = 0
	for i in range(1, n):
		res += a[i]
		max_res = max(max_res, res)
		if res < 0:
			res = 0
	if max_res < sum_all:
		print('YES')
	else:
		print('NO')


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	t1 = 0
	for i in a:
		t1 += i
	ans = a[0]
	ans_l = 0
	ans_r = 0
	count = 0
	minus_pos = -1
	for i in range(n):
		count += a[i]
		if count > ans:
			ans = count
			ans_l = minus_pos + 1
			ans_r = i
		if count <= 0:
			count = 0
			minus_pos = i
	if ans == t1 and ans_l == 0 and (ans_r == n - 1):
		print('YES')
	else:
		print('NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


def maxx(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	tot = sum(a)
	su = maxx(a[1:], n - 1)
	nu = maxx(a[:-1], n - 1)
	ans = max(su, nu)
	if tot > ans:
		print('YES')
	else:
		print('NO')


def isYasserHappy(tastiness):
	summation = 0
	total_sum = sum(tastiness)
	for i in range(len(tastiness)):
		if tastiness[i] <= 0 and (-tastiness[i] >= summation or -tastiness[i] >= total_sum - summation - tastiness[i]):
			return 'NO'
		summation += tastiness[i]
	return 'YES'
useless = int(input())
for i in range(useless):
	nums = int(input())
	tasty = [int(i) for i in input().split()]
	print(isYasserHappy(tasty))


def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -100000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -100000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def maxSubArraySum(arr, l, h):
	if l == h:
		return arr[l]
	m = (l + h) // 2
	return max(maxSubArraySum(arr, l, m), maxSubArraySum(arr, m + 1, h), maxCrossingSum(arr, l, m, h))
tc = int(input())
for i in range(tc):
	n = int(input())
	tas = list(map(int, input().split()))
	tempAns = max(maxSubArraySum(tas, 0, n - 2), maxSubArraySum(tas, 1, n - 1))
	if sum(tas) > tempAns:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	poss = False
	s1 = s2 = 0
	for i in range(n):
		s1 += a[i]
		if s1 <= 0:
			poss = True
	for i in range(n - 1, -1, -1):
		s2 += a[i]
		if s2 <= 0:
			poss = True
	if poss:
		print('NO')
	else:
		print('YES')


def maxSubArraySum(a, t, size):
	max_so_far = a[t]
	curr_max = a[t]
	for i in range(t + 1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
a = int(input())
while a != 0:
	b = int(input())
	mylist = list(map(int, input().split()))
	p = sum(mylist)
	q = maxSubArraySum(mylist, 0, b - 1)
	r = maxSubArraySum(mylist, 1, b)
	if q >= p or r >= p:
		print('NO')
	else:
		print('YES')
	a -= 1


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = 0
	for j in arr:
		if j >= 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	if flag == 1:
		sume = 0
		maxe = 0
		leng = 0
		tot = sum(arr)
		for j in range(n):
			if leng >= len(arr) - 1:
				break
			elif j == 0 and arr[j] == 0:
				sume += arr[j]
			else:
				if arr[j] < 0:
					if sume > maxe:
						maxe = sume
				sume += arr[j]
				leng += 1
				if sume <= 0:
					sume = 0
					leng = 0
		if maxe < sume:
			maxe = sume
		if tot > maxe:
			print('YES')
		else:
			print('NO')


t = int(input())
for k in range(t):
	n = int(input())
	tasty = list(map(int, input().split()))
	s = sum(tasty)
	start = 0
	end = 0
	s_temp = 0
	max_sum = tasty[0]
	if max_sum < 0:
		max_sum = 0
	current_sum = max_sum
	for i in range(1, n):
		temp = tasty[i]
		if temp >= 0:
			current_sum += temp
		elif current_sum + temp > 0:
			if current_sum > max_sum:
				max_sum = current_sum
				end = i
				start = s_temp
			current_sum += temp
		else:
			current_sum = 0
			s_temp = i
	if current_sum > max_sum:
		max_sum = current_sum
		start = s_temp
		end = i
	for c in range(start, end):
		if tasty[c] == 0:
			start += 1
		else:
			break
	m = max(tasty)
	if m < max_sum and max_sum == 0:
		max_sum = m
		start = end = 0
	if max_sum < s:
		print('YES')
	elif max_sum == s and end - start == n - 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	total_sum = sum(x)
	cur_sum = cur_max = cnt_zeros = 0
	flag = 0
	for j in range(n):
		if x[j] < 0:
			cnt_zeros += 1
		if x[j] >= total_sum or cur_sum >= total_sum:
			print('NO')
			break
		cur_sum += x[j]
		if cur_sum <= 0:
			cur_sum = 0
			flag = 1
		if cur_sum > cur_max:
			cur_max = cur_sum
		if j == n - 1 and (cnt_zeros == 0 or (cur_sum == total_sum and flag == 0)):
			print('YES')
		if j == n - 1 and (cur_sum > total_sum or flag == 1):
			print('NO')
			break


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	a = inpl()
	aa = list(itertools.accumulate(a))
	mi = 0
	ma = aa[-1]
	ok = True
	for i in range(n - 1):
		if aa[i] <= 0 or aa[i] >= ma:
			ok = False
			break
	print('YES' if ok else 'NO')


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d

def maxSubArraySum1(a, size):
	max_so_far = 0
	curr_max = 0
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far

def maxSubArraySum2(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size - 1):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	sm = 0
	for i in a:
		sm += i
	if sm > maxSubArraySum1(a, n) and sm > maxSubArraySum2(a, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	sum1 = sum(a)
	temp = 0
	for i in range(n - 1):
		temp += a[i]
		if temp <= 0:
			print('NO')
			break
		if temp >= sum1:
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = (int(input()), list(map(int, input().split())))
	yaser = sum(m)
	adel = m[0]
	(curr, l) = (0, 0)
	for (ind, i) in enumerate(m):
		if curr <= 0:
			l = ind
			curr = 0
		curr += i
		if ind != n - 1 or l != 0:
			adel = max(adel, curr)
	print('YES' if yaser > adel else 'NO')


from sys import stdin, stdout
import gc
from copy import deepcopy
from itertools import permutations
gc.disable()
input = stdin.readline
import math
maxint = float('inf')

def maxSubArraySum(a):
	size = len(a)
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = list(map(int, input().split()))
	if sum(arr) <= maxSubArraySum(arr[1:]):
		print('NO')
		continue
	elif sum(arr) <= maxSubArraySum(arr[:len(arr) - 1]):
		print('NO')
		continue
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	i = 0
	s = 0
	max = 0
	k = -1
	j = [0, 0]
	while i < n:
		s += a[i]
		if s <= 0:
			k = i
			f = 1
			s = 0
		if s > max:
			j[0] = k + 2
			j[1] = i + 1
			max = s
		i += 1
	if max > sum(a):
		print('NO')
	else:
		print('YNEOS'[j[1] - j[0] + 1 != n::2])


def solve(n, cakes):
	total = 0
	adelMaximum = None
	temp = None
	adelTakeAll = False
	numElementsAdel = 0
	for score in cakes:
		total += score
		if temp is None:
			temp = score
			numElementsAdel = 1
		elif temp <= 0:
			temp = score
			numElementsAdel = 1
		elif temp > 0:
			temp += score
			numElementsAdel += 1
		if adelMaximum is None or temp > adelMaximum:
			adelMaximum = temp
			if numElementsAdel == n:
				adelTakeAll = True
	if adelTakeAll:
		adelMaximum -= min(cakes[0], cakes[-1])
	if total > adelMaximum:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	print(solve(n, c))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	line = sys.stdin.readline().split()
	nums = list(map(int, line))
	acc = [0] * n
	maxc = nums[0]
	minc = nums[0]
	acc[0] = nums[0]
	yasser = nums[0]
	adel = nums[0]
	for i in range(1, n):
		acc[i] = acc[i - 1] + nums[i]
		if acc[i] < minc:
			minc = acc[i]
		else:
			maxc = acc[i]
		if i < n - 1:
			if max(maxc, maxc - minc) > adel:
				adel = max(maxc, maxc - minc)
		elif maxc - minc > adel:
			adel = maxc - minc
		yasser += nums[i]
	if yasser > adel:
		print('YES')
	else:
		print('NO')


from sys import maxsize

def algg(a):
	n = len(a)
	l = 0
	maxim = -maxsize - 1
	for i in range(n):
		l = l + a[i]
		if maxim < l:
			maxim = l
		if l < 0:
			l = 0
	return maxim
q = int(input())
while q > 0:
	n = int(input())
	a = list(map(int, input().split()))
	W = 0
	for i in a:
		W += i
	ans1 = algg(a[1:])
	ans2 = algg(a[0:n - 1])
	ans = max(ans1, ans2)
	if W > ans:
		print('YES')
	else:
		print('NO')
	q -= 1


def maximum_sum(nums):
	cur_sum1 = 0
	best_sum1 = float('-inf')
	for i in range(0, len(nums) - 1):
		cur_sum1 = max(cur_sum1 + nums[i], nums[i])
		best_sum1 = max(cur_sum1, best_sum1)
	cur_sum2 = 0
	best_sum2 = float('-inf')
	for i in range(1, len(nums)):
		cur_sum2 = max(cur_sum2 + nums[i], nums[i])
		best_sum2 = max(cur_sum2, best_sum2)
	return max(best_sum1, best_sum2)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if sum(arr) > maximum_sum(arr):
		print('YES')
	else:
		print('NO')


def isHappy(vals):
	front = 0
	back = 0
	for a in range(len(vals)):
		front -= vals[a]
		if front >= 0:
			return 'NO'
	for b in range(len(vals) - 1, -1, -1):
		back -= vals[b]
		if back >= 0:
			return 'NO'
	return 'YES'
n = int(input())
for a in range(n):
	input()
	vals = list(map(int, input().split()))
	print(isHappy(vals))


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mx = curr = sum = 0
	for x in a:
		sum = sum + x
	for x in a[:n - 1]:
		curr = curr + x
		if curr < 0:
			curr = 0
		elif mx < curr:
			mx = curr
	curr = 0
	for x in a[1:]:
		curr = curr + x
		if curr < 0:
			curr = 0
		elif mx < curr:
			mx = curr
	if sum > mx:
		print('YES')
	else:
		print('NO')


def maxim_sum(mass, n):
	answer = mass[0]
	ind1 = 0
	ind2 = 0
	s = 0
	min_sum = 0
	min_pos = -1
	for i in range(n):
		s += mass[i]
		razn = s - min_sum
		if razn > answer:
			answer = razn
			ind1 = min_pos + 1
			ind2 = i
		if s < min_sum:
			min_sum = s
			min_pos = i
	return (ind1 + 1, ind2 + 1, answer)
n = int(input())
for i in range(n):
	m = int(input())
	arr = [int(x) for x in input().split()]
	(x, y, s1) = maxim_sum(arr, m)
	s2 = sum(arr)
	if x == 1 and y == m:
		q = s1
		f = False
		for j in range(m):
			q -= arr[j]
			if q >= s2:
				print('NO')
				f = True
				break
		q = s1
		if f:
			continue
		for j in range(m - 1, -1, -1):
			q -= arr[j]
			if q >= s2:
				print('NO')
				f = True
				break
		if f:
			continue
		print('YES')
	elif s2 > s1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	(maxCurr, maxAdel) = (0, min(l) - 1)
	for i in range(0, n - 1):
		maxCurr = max(0, maxCurr + l[i])
		maxAdel = max(maxAdel, maxCurr)
	maxCurr = 0
	for i in range(1, n):
		maxCurr = max(0, maxCurr + l[i])
		maxAdel = max(maxAdel, maxCurr)
	print('YES' if s > maxAdel else 'NO')


def fun(l, i, j):
	m = l[i]
	p = 0
	for i in range(i, j + 1):
		p += l[i]
		if p > m:
			m = p
		if p < 0:
			p = 0
	return m
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = sum(l)
	m = max(fun(l, 0, n - 2), fun(l, 1, n - 1))
	if c > m:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	yas = sum(a)
	b = a[1:]
	c = a[0:len(a) - 1]
	cursum = 0
	ans1 = min(b)
	ans2 = min(c)
	for i in range(len(b)):
		cursum = cursum + b[i]
		ans1 = max(ans1, cursum)
		if cursum < 0:
			cursum = 0
	cursum = 0
	for i in range(len(c)):
		cursum = cursum + c[i]
		ans2 = max(ans2, cursum)
		if cursum < 0:
			cursum = 0
	adel = max(ans1, ans2)
	adel = max(adel, a[0])
	adel = max(adel, a[-1])
	if adel >= yas:
		print('NO')
	else:
		print('YES')
	t = t - 1


for t in range(int(input())):
	n = int(input())
	ar = [int(x) for x in input().split()]
	lsum = 0
	flag = False
	for k in range(n):
		lsum += ar[k]
		if lsum <= 0:
			flag = True
	rsum = 0
	for k in range(n - 1, -1, -1):
		rsum += ar[k]
		if rsum <= 0:
			flag = True
	print('NO' if flag else 'YES')


t = int(input())

def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	ab = a[1:]
	ac = a[:-1]
	if max(maxSubArraySum(ab, n - 1), maxSubArraySum(ac, n - 1)) >= y:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	prefix = [[0, 0]]
	s = 0
	for i in range(n):
		s += a[i]
		prefix.append([s, i + 1])
	prefix.sort()
	if prefix[-1][1] == n and prefix[0][1] == 0:
		diff = max(prefix[-2][0] - prefix[0][1], prefix[-1][0] - prefix[1][0])
	else:
		diff = prefix[-1][0] - prefix[0][0]
	if diff < sum(a):
		print('YES')
	else:
		print('NO')
	t -= 1


a = int(input())
for i in range(0, a):
	b = int(input())
	c = [int(x) for x in input().split()]
	summ = 0
	tsum = 0
	ttsum = 0
	totalcount = 0
	count = 0
	for i in range(0, b):
		summ += c[i]
		if tsum <= 0 and i != 0:
			count = 0
			tsum = 0
		tsum += c[i]
		count += 1
		if tsum > ttsum and count != b:
			ttsum = tsum
			totalcount = count
	if count == b:
		tsum = summ - min(c[0], c[b - 1])
		if tsum > ttsum:
			ttsum = tsum
	if summ > ttsum:
		print('YES')
	else:
		print('NO')


import sys
for i in range(int(input())):
	n = int(sys.stdin.readline().lstrip().rstrip())
	arr = list(map(int, input().split()))
	f = 'YES'
	m = 0
	for i in range(n - 1, 0, -1):
		m += arr[i]
		if m <= 0:
			f = 'NO'
	m = 0
	for i in range(n - 1):
		m += arr[i]
		if m <= 0:
			f = 'NO'
	print(f)


t = int(input())
for i in range(0, t):
	c = int(input())
	b = list(input().split(' '))
	total = 0
	izq = 0
	der = 0
	a = 0
	for i in range(0, c):
		b[i] = int(b[i])
		total += b[i]
	while (izq > 0 and der > 0) and a <= c - 1 or a == 0:
		izq += b[a]
		der += b[c - 1 - a]
		a += 1
	if der > 0 and izq > 0:
		print('YES')
	else:
		print('NO')


cases = int(input())
arr = []
while cases != 0:
	n = int(input())
	arr = list(map(int, input().split()))
	suma = 0
	can = True
	for i in range(0, len(arr)):
		suma += arr[i]
		if suma <= 0:
			can = False
	suma = 0
	for i in range(len(arr) - 1, -1, -1):
		suma += arr[i]
		if suma <= 0:
			can = False
	if can == True:
		print('YES')
	else:
		print('NO')
	cases -= 1


def max_segment_drop_first(cupcakes):
	best = 0
	current = 0
	for i in range(1, len(cupcakes)):
		c = cupcakes[i]
		current = max(0, current + c)
		best = max(best, current)
	return best

def max_segment_drop_last(cupcakes):
	best = 0
	current = 0
	for i in range(len(cupcakes) - 1):
		c = cupcakes[i]
		current = max(0, current + c)
		best = max(best, current)
	return best

def solve(cupcakes):
	adel = max(max_segment_drop_first(cupcakes), max_segment_drop_last(cupcakes))
	yasser = sum(cupcakes)
	return yasser > adel
T = int(input())
res = []
for _ in range(T):
	_ = input()
	cupcakes = list(map(int, input().split()))
	res.append(solve(cupcakes))
for r in res:
	if r:
		print('YES')
	else:
		print('NO')


class Solution:

	def solve(self, cupCakesTastiness):
		if not cupCakesTastiness or len(cupCakesTastiness) == 0:
			return False
		n = len(cupCakesTastiness)
		yasserTastiness = sum(cupCakesTastiness)
		dp = [(0, 0) for _ in range(n)]
		dp[0] = (cupCakesTastiness[0], 0)
		if dp[0][0] >= yasserTastiness:
			return False
		for i in range(1, n):
			mMax = max(cupCakesTastiness[i], cupCakesTastiness[i] + dp[i - 1][0])
			if mMax == cupCakesTastiness[i]:
				dp[i] = (mMax, i)
			else:
				dp[i] = (mMax, dp[i - 1][1])
			if dp[i][1] == 0 and i == n - 1:
				minOfFirstAndLast = min(cupCakesTastiness[n - 1], cupCakesTastiness[0])
				dp[i] = (dp[i][0] - minOfFirstAndLast, dp[i][1])
			if dp[i][0] >= yasserTastiness:
				return False
		return True
sol = Solution()
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	cupCakesTastiness = list(map(int, input().strip().split()))
	print('YES' if sol.solve(cupCakesTastiness=cupCakesTastiness) else 'NO')


def fns(arr, n, x):
	curr_sum = 0
	start = 0
	end = 0
	ans = False
	while end < n:
		while curr_sum <= x and end < n:
			if curr_sum <= 0 and x > 0:
				start = end
				curr_sum = 0
			curr_sum += arr[end]
			end += 1
			if curr_sum == x and end - start != n:
				ans = True
		while curr_sum > x and start < n:
			return True
	return ans
for a0 in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = sum(arr)
	ans = fns(arr, n, x)
	if ans:
		print('NO')
	else:
		print('YES')


def maxsum(a, n):
	maxtil = a[0]
	curmax = a[0]
	for i in range(1, n):
		curmax = max(a[i], curmax + a[i])
		maxtil = max(maxtil, curmax)
	return maxtil
for tc in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	g = max(maxsum(l, n - 1), maxsum(l[1:], n - 1))
	if sum(l) > g:
		print('YES')
	else:
		print('NO')


def get_max(ar, start, end):
	(ans, cur) = (0, 0)
	for i in range(start, end):
		cur += ar[i]
		cur = max(0, cur)
		ans = max(ans, cur)
	return ans
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	first = sum(ar)
	second = max(get_max(ar, 0, n - 1), get_max(ar, 1, n))
	print('YES' if first > second else 'NO')


n = int(input())
while n != 0:
	(n, k, a) = (n - 1, 0, int(input()))
	b = list(map(int, input().split()))
	(i, s) = (0, 0)
	while i != a:
		s = s + b[i]
		if s <= 0:
			print('NO')
			k = 1
			break
		i = i + 1
	if k == 0:
		(s, i) = (0, a - 1)
		while i >= 0:
			s = s + b[i]
			if s <= 0:
				print('NO')
				k = 1
				break
			i = i - 1
	if k == 0:
		print('YES')


def max_subarray(numbers):
	best_sum = 0
	current_sum = 0
	for x in numbers:
		current_sum = max(0, current_sum + x)
		best_sum = max(best_sum, current_sum)
	return best_sum
t = int(input())
while t > 0:
	n = int(input())
	ns = [int(k) for k in input().split()]
	yaser = sum(ns)
	adel = max(max_subarray(ns[0:-1]), max_subarray(ns[1:]))
	if yaser > adel:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	prefixSum = 0
	for e in a:
		prefixSum += e
		if prefixSum <= 0:
			print('NO')
			return
	suffixSum = 0
	for e in reversed(a):
		suffixSum += e
		if suffixSum <= 0:
			print('NO')
			return
	print('YES')
for _ in range(t):
	solve()


import math
for _ in range(int(input())):
	n = int(input())
	cake = [int(x) for x in input().split()]
	(s1, s2, adel) = (0, 0, -100000000000)
	for c in cake:
		s1 += c
	a_c = cake[1:]
	for c in a_c:
		s2 += c
		adel = max(adel, s2)
		if s2 < 0:
			s2 = 0
	s2 = 0
	a_c = cake[:-1]
	for c in a_c:
		s2 += c
		adel = max(adel, s2)
		if s2 < 0:
			s2 = 0
	print('YES') if s1 > adel else print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sum_a = sum(a)
	INF = 10 ** 18
	dp = [-INF] * (n + 1)
	dp[0] = 0
	for i in range(n):
		dp[i + 1] = max(a[i], dp[i] + a[i])
	tmp = max(dp[0:n])
	pos = 0
	for i in range(n)[::-1]:
		if i == 0:
			break
		pos += a[i]
		tmp = max(tmp, pos)
	if sum_a <= tmp:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	sm = 0
	sm1 = 0
	msm = 0
	msm1 = 0
	for i in range(n):
		s = s + l[i]
	for i in range(n - 1):
		sm = sm + l[i]
		if sm > 0:
			msm = max(msm, sm)
		else:
			sm = 0
			msm = 0
	for i in range(1, n):
		sm1 = sm1 + l[i]
		if sm1 > 0:
			msm1 = max(msm1, sm1)
		else:
			sm1 = 0
			msm1 = 0
	k = max(msm, msm1)
	if s > k:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	f = 0
	b = [0] * n
	s = sum(a)
	b[0] = a[0]
	x = 0
	for i in range(1, n):
		b[i] = a[i] + b[i - 1]
	for i in range(0, n - 1):
		if b[i] <= 0 or b[i] >= s:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	while t:
		_ = int(input())
		a = list(map(int, input().split()))
		mx = a[0]
		cur = 0
		for num in a[:-1]:
			if cur < 0:
				cur = 0
			cur += num
			if cur > mx:
				mx = cur
		cur = 0
		for num in a[1:]:
			if cur < 0:
				cur = 0
			cur += num
			if cur > mx:
				mx = cur
		if mx < sum(a):
			print('YES')
		else:
			print('NO')
		t -= 1
main()


def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -10000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -1000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def maxSubArraySum(arr, l, h):
	if l == h:
		return arr[l]
	m = (l + h) // 2
	return max(maxSubArraySum(arr, l, m), maxSubArraySum(arr, m + 1, h), maxCrossingSum(arr, l, m, h))
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mxsum1 = maxSubArraySum(a, 0, n - 2)
	mxsum2 = maxSubArraySum(a, 1, n - 1)
	mx = max(mxsum1, mxsum2)
	mx_y = sum(a)
	if mx_y > mx:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	Yas = sum(l)
	sum1 = l[0]
	max1 = sum1
	for i in range(1, n - 1):
		sum1 = max(sum1 + l[i], l[i])
		if sum1 > max1:
			max1 = sum1
	max2 = l[n - 1]
	sum2 = max2
	for i in range(n - 2, 0, -1):
		sum2 = max(sum2 + l[i], l[i])
		if sum2 > max2:
			max2 = sum2
	Ad = max(max1, max2)
	if Ad < Yas:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cur = 0
	ans = -10 ** 9
	tot = a[0]
	flag = 0
	for j in range(1, n):
		cur += a[j]
		tot += a[j]
		ans = max(ans, cur)
		cur = max(0, cur)
	cur = 0
	for j in range(n - 1):
		cur += a[j]
		ans = max(ans, cur)
		cur = max(0, cur)
	if tot > ans:
		print('YES')
	else:
		print('NO')


import os
from math import ceil
import sys
from io import BytesIO, IOBase
import sys, bisect, copyreg, copy, statistics, os
import random

def inp():
	return sys.stdin.readline().strip()

def IIX():
	return (int(x) for x in sys.stdin.readline().split())

def II():
	return int(inp())

def LI():
	return list(map(int, inp().split()))

def LS():
	return list(map(str, inp().split()))

def L(x):
	return list(x)

def out(var):
	return sys.stdout.write(str(var))

class GraphAL:

	def __init__(self, Nodes, isDirected=False):
		self.nodes = [x for x in range(1, Nodes + 1)]
		self.adj_list = {}
		self.isDirected = isDirected
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, x, y):
		self.adj_list[x].append(y)
		if self.isDirected == False:
			self.adj_list[y].append(x)

	def return_graph(self):
		return self.adj_list

class GraphAM:

	def __init__(self, Nodes, isDirected=False):
		self.adj_matrix = [[0] * (Nodes + 1) for x in range(Nodes + 2)]
		self.isDirected = isDirected

	def add_edge(self, x, y):
		if self.isDirected:
			self.adj_matrix[x][y] = 1
		elif self.isDirected == False:
			self.adj_matrix[x][y] = 1
			self.adj_matrix[y][x] = 1

	def delete_edge(self, x, y):
		if self.isDirected:
			self.adj_matrix[x][y] = 0
		if self.isDirected == False:
			self.adj_matrix[x][y] = 0
			self.adj_matrix[y][x] = 0

	def degree(self, x):
		l = self.adj_matrix[x]
		return l.count(1)

	def return_graph(self):
		return self.adj_matrix

def solve():
	n = II()
	tastiness = LI()
	s = 0
	for i in range(n):
		s += tastiness[i]
		if s <= 0:
			out('NO\n')
			return
	s = 0
	for i in range(n - 1, -1, -1):
		s += tastiness[i]
		if s <= 0:
			out('NO\n')
			return
	out('YES\n')
	return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
try:
	t = II()
	for _ in range(t):
		solve()
except EOFError as e:
	out('')
except RuntimeError as r:
	out('')


from os import truncate
for s in [*open(0)][2::2]:
	a = [*map(int, s.split())]
	sz = len(a)
	l = r = 0
	for i in range(sz - 1):
		l += a[i]
		r += a[sz - i - 1]
		if l < 1 or r < 1:
			print('NO')
			break
	else:
		print('YES')


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))
for (N, A) in Query:
	ok = True
	S = sum(A)
	b = 0
	min_b = 0
	min_ind = -1
	for (i, a) in enumerate(A):
		b += a
		if i == N - 1:
			if min_ind != -1:
				ok = False
				break
		elif b - min_b >= S:
			ok = False
			break
		if b <= min_b:
			min_b = b
			min_ind = i
	print('YES' if ok else 'NO')


def rr():
	return input().rstrip()

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))
from collections import defaultdict

def mus(d=0):
	return defaultdict(defaultdict(d))

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def yn(x):
	return 'YES' if x else 'NO'
from itertools import accumulate

def read():
	n = rri()
	return (rrl(),)

def solve(arr):
	x1 = any(map(lambda x: x <= 0, accumulate(arr)))
	x2 = any(map(lambda x: x <= 0, accumulate(reversed(arr))))
	return yn(not (x1 or x2))
test_count = rri()
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	print(result)


n = int(input())
for i in range(n):
	t = int(input())
	l = list(map(int, input().split()))
	sum1 = 0
	sum2 = 0
	z = float('-inf')
	flag = 0
	flag1 = 0
	dp = [0 for i in range(t + 1)]
	s = 0
	for j in range(t):
		s = s + l[j]
		if l[j] <= 0:
			flag1 = 1
		dp[j + 1] = max(dp[j] + l[j], l[j])
	if flag1 == 0:
		print('YES')
		continue
	for j in range(1, len(dp)):
		if j == t and dp[t] == s and (flag1 == 0):
			break
		elif j == t and dp[t] > s:
			flag = 1
			print('NO')
			break
		elif dp[j] >= s and j < t or dp[j] == 0:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


import bisect
import collections
import re
import sys
import threading
doneflag = 0
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	taste = list(map(int, sys.stdin.readline().strip().split()))
	taste.insert(0, 0)
	p = [0 for _ in range(n + 1)]
	rp = [0 for _ in range(n + 1)]
	for i in range(1, n):
		p[i] = p[i - 1] + taste[i]
		if p[i] <= 0:
			print('NO')
			doneflag = 1
			break
	if doneflag == 1:
		doneflag = 0
		continue
	for i in range(1, n):
		rp[i] = rp[i - 1] + taste[n - i + 1]
		if rp[i] <= 0:
			print('NO')
			doneflag = 1
			break
	if doneflag == 1:
		doneflag = 0
		continue
	print('YES')


cases = int(input())
result = []
for k in range(cases):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	_sum = sum(arr)
	if min(arr) >= 0 and (_sum <= _sum - arr[0] or _sum <= _sum - arr[-1]):
		result.append('NO')
	else:
		prefix_sum = [0] * n
		prefix_sum[0] = arr[0]
		prefix_sum2 = [0] * n
		arr_reversed = list(reversed(arr))
		prefix_sum2[0] = arr_reversed[0]
		flag = True
		for i in range(1, n):
			prefix_sum[i] = prefix_sum[i - 1] + arr[i]
		for i in range(1, n):
			prefix_sum2[i] = prefix_sum2[i - 1] + arr_reversed[i]
		for i in range(n - 1):
			if prefix_sum[i] <= 0:
				result.append('NO')
				flag = False
				break
		if flag:
			for i in range(n - 1):
				if prefix_sum2[i] <= 0:
					result.append('NO')
					flag = False
					break
		if flag:
			result.append('YES')
for x in result:
	print(x)


import math
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	c1 = 1
	for i in range(n):
		if l[i] <= 0:
			c1 = 0
			break
	if c1 == 1:
		print('YES')
	else:
		y = sum(l)
		s1 = 0
		c = 0
		for i in range(n - 1):
			s1 += l[i]
			if s1 <= 0 or y - s1 <= 0:
				c = 1
				break
		if c == 1:
			print('NO')
		else:
			print('YES')


t = int(input())
for q in range(t):
	flag = True
	n = int(input())
	s = 0
	a = list(map(int, input().split()))
	for i in range(n):
		s += a[i]
		if s <= 0:
			flag = False
	ss = 0
	for i in range(n - 1, -1, -1):
		ss += a[i]
		if ss <= 0:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


def maxSubArraySum(arr, l, r):
	sum_so_far = 0
	max_so_far = -100000000000000000000
	for i in range(l, r):
		sum_so_far += arr[i]
		if sum_so_far > max_so_far:
			max_so_far = sum_so_far
		if sum_so_far < 0:
			sum_so_far = 0
	return max_so_far
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	mxsum = max(maxSubArraySum(arr, 0, n - 1), maxSubArraySum(arr, 1, n))
	if s > mxsum:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	pre = [l[0]]
	c = l[0]
	for i in range(1, n):
		pre.append(c + l[i])
		c = pre[-1]
	suff = [l[-1]]
	c = suff[-1]
	for i in range(n - 2, -1, -1):
		suff.append(c + l[i])
		c = suff[-1]
	flag = False
	for i in range(n):
		if pre[i] <= 0 or suff[i] <= 0:
			print('NO')
			flag = True
			break
	if flag == False:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	se = set()
	for i in range(1, n):
		s = max(a[i], s + a[i])
		se.add(s)
	s = 0
	for i in range(n - 1):
		s = max(a[i], s + a[i])
		se.add(s)
	mx = max(se)
	print('YES' if sum(a) > mx else 'NO')


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		lst = [0] * n
		lst[0] = a[0]
		total_max = lst[0]
		idx_max = 0
		Yasser = a[0]
		for i in range(1, n):
			Yasser += a[i]
			lst[i] = lst[i - 1] + a[i]
			if total_max < lst[i]:
				total_max = lst[i]
				idx_max = i
		total_min = 0
		idx_min = 0
		for i in range(idx_max):
			if lst[i] <= total_min:
				total_min = lst[i]
				idx_min = i
		Adel = total_max - total_min
		if idx_max == n - 1 and idx_min == 0:
			Adel -= min(a[0], a[n - 1])
		if Adel < Yasser:
			print('YES')
		else:
			print('NO')
main()


def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	Sum = sum(L)
	X = 0
	FLAG1 = 0
	FLAG2 = 0
	for i in range(N):
		if L[i] < 0:
			FLAG1 = 1
			break
	for i in range(N):
		if L[i] > 0:
			FLAG2 = 1
			break
	if FLAG1 == 0 and FLAG2 == 1:
		print('YES')
	elif FLAG1 == 1 and FLAG2 == 0:
		print('NO')
	elif FLAG1 == 0 and FLAG2 == 0:
		print('NO')
	else:
		sum1 = maxSubArraySum(L[1:], N - 1)
		sum2 = maxSubArraySum(L[:N], N - 1)
		X = max(sum1, sum2)
		if Sum > X:
			print('YES')
		else:
			print('NO')


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = list(map(int, input().split()))
		flg = 1
		for a in A:
			if a < 0:
				flg = 0
				break
		if flg:
			if A[0] > 0 and A[-1] > 0:
				print('YES')
			else:
				print('NO')
			continue
		cs = [0] * (N + 1)
		for i in range(N):
			cs[i + 1] = cs[i] + A[i]
		m = 10 ** 9 + 7
		ans = -10 ** 10
		for i in range(N - 1):
			if cs[i] < m:
				m = cs[i]
			ans = max(ans, cs[i + 1] - m)
		ans = max(ans, cs[-1] - min(cs[1:]))
		if sum(A) > ans:
			print('YES')
		else:
			print('NO')
main()


def cal(aa, bb):
	Sum = 0
	best = 0
	for i in range(aa, bb):
		Sum = max(Sum + a[i], a[i])
		best = max(best, Sum)
	return best
for q in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	su = sum(a)
	be = cal(0, n - 1)
	be1 = cal(1, n)
	be = max(be, be1)
	print('YES' if su > be else 'NO')


def fun(a, n):
	dp = [0] * (n + 1)
	s = 0
	for i in range(n):
		s += a[i]
		dp[i + 1] = s
	yasser = dp[n]
	for i in range(1, n + 1):
		if i != n and dp[i] <= 0:
			print('NO')
			return ''
		if i != 1 and dp[n] - dp[i - 1] <= 0:
			print('NO')
			return ''
	print('YES')
	return ''
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fun(a, n)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	yasser = sum(a)
	ans = True
	cur = 0
	for i in range(n - 1):
		cur += a[i]
		if cur <= 0:
			ans = False
			break
	cur = 0
	for i in reversed(range(1, n)):
		cur += a[i]
		if cur <= 0:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


t = int(input())
while t:
	t = t - 1
	flag = 1
	n = int(input())
	r = list(map(int, input().split()))
	sum = 0
	for i in range(n):
		sum = sum + r[i]
		if sum <= 0:
			flag = 0
	s = 0
	for i in range(n - 1, -1, -1):
		s = s + r[i]
		if s <= 0:
			flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	t = True
	if max(arr) >= s:
		print('NO')
	else:
		v = [arr[0]]
		g = False
		for i in range(1, n - 1):
			if v[-1] + arr[i] <= arr[i]:
				g = True
			v.append(max(v[-1] + arr[i], arr[i]))
		if g:
			v.append(max(v[-1] + arr[-1], arr[-1]))
		if max(v) >= s:
			print('NO')
		else:
			print('YES')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def mcs(l):
	s = -10 ** 20
	ans = -10 ** 20
	d = defaultdict(int)
	for i in range(len(l)):
		s = max(l[i], s + l[i])
		ans = max(ans, s)
	return ans
t = I()
for _ in range(t):
	n = I()
	l = L()
	s = sum(l)
	p = mcs(l[:n - 1])
	q = mcs(l[1:])
	if s > max(p, q):
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ps = [0]
	for i in range(n):
		ps.append(ps[-1] + l[i])
	i = 0
	j = 1
	m = 0
	p = 0
	k = 0
	for w in range(len(l)):
		if m < ps[j] - ps[i]:
			m = ps[j] - ps[i]
			k = j
			p = i
		if ps[j] - ps[i] <= 0:
			i = j
			j += 1
		else:
			j += 1
	if m == ps[-1] and (p != 0 or k != n):
		print('NO')
	elif m == ps[-1] and p == 0 and (k == n):
		print('YES')
	elif m < ps[-1]:
		print('YES')
	else:
		print('NO')


def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -10000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -1000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def maxSubArraySum(arr, l, h):
	if l == h:
		return arr[l]
	m = (l + h) // 2
	return max(maxSubArraySum(arr, l, m), maxSubArraySum(arr, m + 1, h), maxCrossingSum(arr, l, m, h))
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maxsum1 = maxSubArraySum(arr, 0, n - 2)
	maxsum2 = maxSubArraySum(arr, 1, n - 1)
	mxx = max(maxsum1, maxsum2)
	mxy = sum(arr)
	if mxy > mxx:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')

def read():
	n = int(input())
	a = list(map(int, input().split()))
	return (n, a)

def solve(n, a):
	(s1, s2) = (0, 0)
	for i in range(n - 1):
		s1 += a[i]
		s2 += a[n - 1 - i]
		if s1 <= 0 or s2 <= 0:
			return False
	return True
for t in range(int(input())):
	result = solve(*read())
	print('YES' if result else 'NO')


import copy
for i in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	m = copy.deepcopy(l)
	l.sort()
	if l[0] > 0:
		print('YES')
	else:
		max_sum = l[1]
		now_max_sum = 0
		for i in range(n - 1):
			now_max_sum += m[i]
			if max_sum <= now_max_sum:
				max_sum = now_max_sum
			if now_max_sum < 0:
				now_max_sum = 0
		now_max_sum = 0
		for i in range(1, n):
			now_max_sum += m[i]
			if max_sum <= now_max_sum:
				max_sum = now_max_sum
			if now_max_sum < 0:
				now_max_sum = 0
		if max_sum < sum(l):
			print('YES')
		else:
			print('NO')


def f(l):
	if len(l) == 1:
		return 0
	else:
		mid = len(l) // 2
		p1 = l[:mid]
		p2 = l[mid:]
		return max(f(p1), f(p2), max(p2) - min(p1))
for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	p_sum = [arr[0]]
	for i in range(1, n):
		p_sum.append(p_sum[-1] + arr[i])
	j1 = sum(arr)
	j2 = f(p_sum)
	for i in range(n - 1):
		j2 = max(j2, p_sum[i])
	if j1 <= j2:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def main():
	global ret
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		n1 = n2 = 0
		flag = False
		for i in range(len(arr)):
			n1 += arr[i]
			n2 += arr[n - 1 - i]
			if n1 <= 0 or n2 <= 0:
				flag = True
		if flag:
			print('NO')
		else:
			print('YES')
main()


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	p = 0
	flag = 1
	for i in range(n):
		p += a[i]
		if p <= 0:
			flag = 0
			break
	if flag:
		s = 0
		for i in range(n - 1, -1, -1):
			s += a[i]
			if s <= 0:
				flag = 0
				break
	ans += 'YNEOS'[not flag::2] + '\n'
print(ans)


def f(L):
	s = sum(L)
	L2 = [0] * len(L)
	if L == L2:
		return 'NO'
	L3 = [0] * len(L)
	for i in range(len(L)):
		L2[i] = L[i]
	pos = True
	for i in range(len(L)):
		if L[i] < 0:
			pos = False
			break
	if pos == True:
		return 'YES'
	else:
		for j in range(1, len(L)):
			a = L2[j]
			b = L2[j] + L2[j - 1]
			if a >= b:
				L3[j] = j
				L2[j] = a
			else:
				L3[j] = L3[j - 1]
				L2[j] = b
		for i in range(len(L) - 1):
			if L2[i] >= s:
				return 'NO'
		if L2[len(L) - 1] >= s and L3[len(L) - 1] != 0:
			return 'NO'
		return 'YES'
n = int(input(''))
for i in range(n):
	s = int(input(''))
	z = [int(x) for x in input('').split()]
	print(f(z))


def main():
	t = int(input())
	while t > 0:
		n = int(input())
		x = input().split()
		arr = []
		sum = 0
		for i in x:
			arr.append(int(i))
			sum += int(i)
		start = 0
		end = 0
		s = 0
		max = 0
		cur = 0
		for i in range(len(arr)):
			cur += arr[i]
			if cur > max:
				max = cur
				start = s
				end = i
			if cur <= 0:
				cur = 0
				s = i + 1
		if start == 0 and end == n - 1:
			max = max - min(arr[0], arr[n - 1])
		if max < sum:
			print('YES')
		else:
			print('NO')
		t -= 1
main()


def sum(a, n):
	sum = 0
	for i in a:
		sum += i
		if sum <= 0:
			return False
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += a[i]
		if sum <= 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	ai = [*map(int, input().split())]
	k = sum(ai, n)
	if k:
		print('YES')
	else:
		print('NO')


for cases in range(int(input())):
	n = int(input())
	flag = 0
	zero = 0
	l = list(map(int, input().split()))
	max1 = 0
	maxend = 0
	count = 0
	maxc = 0
	for i in range(0, n):
		maxend = maxend + l[i]
		count += 1
		if max1 < maxend:
			max1 = maxend
			maxc = count
		if maxend <= 0:
			maxend = 0
			count = 0
	max2 = sum(l)
	if max2 > max1:
		print('YES')
	elif max2 == max1 and maxc == n:
		print('YES')
	else:
		print('NO')


def f():
	n = int(input())
	A = [int(s) for s in input().split()]
	am = 0
	for i in range(n):
		am += A[i]
		if am <= 0:
			return 'NO'
	am = 0
	for i in range(n - 1, -1, -1):
		am += A[i]
		if am <= 0:
			return 'NO'
	return 'YES'
t = int(input())
for x in range(t):
	print(f())


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	supre = 0
	susuf = 0
	neg = 0
	for i in range(0, n, 1):
		supre += li[i]
		if supre <= 0:
			neg = 1
			break
	if neg == 0:
		for i in range(n - 1, -1, -1):
			susuf += li[i]
			if susuf <= 0:
				neg = 1
				break
	if neg == 1:
		print('NO')
	else:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
testcases = int(input())
for j in range(testcases):
	n = int(input())
	tasty = list(map(int, input().split()))
	total = sum(tasty)
	val1 = maxSubArraySum(tasty[1:], n - 1)
	val2 = maxSubArraySum(tasty[:-1], n - 1)
	val = max(val1, val2)
	if val >= total:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	max_sum = -999999
	max_ending_here = 0
	for i in range(n - 1):
		max_ending_here = max_ending_here + arr[i]
		if max_sum < max_ending_here:
			max_sum = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	max_ending_here = 0
	for i in range(1, n):
		max_ending_here = max_ending_here + arr[i]
		if max_sum < max_ending_here:
			max_sum = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	if max_sum < sum(arr):
		print('YES')
	else:
		print('NO')


import random

def solve():
	n = int(input())
	arr = [*map(int, input().split())]
	yaser = sum(arr)
	max_adel = arr[0]
	curr_adel = arr[0]
	lb = 0
	rb = 0
	for i in range(1, len(arr)):
		val = arr[i]
		if curr_adel > 0:
			if lb == 0 and rb == len(arr) - 2:
				max_adel = max(curr_adel, max_adel)
				curr_adel = curr_adel - arr[lb] + val
				max_adel = max(curr_adel, max_adel)
				lb += 1
				rb += 1
			else:
				curr_adel += val
				rb += 1
				max_adel = max(curr_adel, max_adel)
		else:
			curr_adel = val
			max_adel = max(curr_adel, max_adel)
			lb = i
			rb = i
	if yaser > max_adel:
		print('YES')
	else:
		print('NO')

def brute_solve(arr):
	mx = arr[0]
	for i in range(0, len(arr)):
		for j in range(i + 1, len(arr) + 1):
			if i == 0 and j == len(arr) + 1:
				continue
			mx = max(mx, sum(arr[i:j]))
	return mx
t = int(input())
for _ in range(t):
	solve()


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	(x, y) = (0, 0)
	f = 0
	for i in range(n):
		x = x + l[i]
		if x <= 0:
			f = 1
			break
	for i in range(n - 1, -1, -1):
		y += l[i]
		if y <= 0:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	nn = [int(i) for i in input().split()]
	ss = []
	sum = 0
	for i in nn:
		sum += i
		ss.append(sum)
	no = False
	for s in ss:
		if s <= 0:
			no = True
			print('NO')
			break
	if not no:
		ss = []
		sum = 0
		for i in reversed(nn):
			sum += i
			ss.append(sum)
		for s in ss:
			if s <= 0:
				no = True
				print('NO')
				break
		if not no:
			print('YES')


def solve(n, l):
	ls = rs = 0
	for i in l:
		ls += i
		if ls <= 0:
			return False
	for i in reversed(l):
		rs += i
		if rs <= 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print('YES' if solve(n, l) else 'NO')


p = int(input())
for j in range(p):
	n = int(input())
	arr = list(map(int, input().split()))
	t = 0
	for i in range(n):
		t += arr[i]
	ans = arr[0]
	s = 0
	ans_l = 0
	ans_r = 0
	min_s = 0
	min_pos = -1
	cur = 0
	for i in range(0, n - 1):
		s += arr[i]
		cur = s - min_s
		if cur > ans:
			ans = cur
			ans_l = min_pos + 1
			ans_r = i
		if s < min_s:
			min_s = s
			min_pos = i
	if ans >= t:
		print('NO')
	else:
		ans = arr[1]
		s = 0
		ans_l = 1
		ans_r = 1
		min_s = 0
		min_pos = -1
		cur = 0
		for i in range(1, n):
			s += arr[i]
			cur = s - min_s
			if cur > ans:
				ans = cur
				ans_l = min_pos + 1
				ans_r = i
			if s < min_s:
				min_s = s
				min_pos = i
		if ans >= t:
			print('NO')
		else:
			ans = arr[0]
			s = 0
			ans_l = 0
			ans_r = 0
			min_s = 0
			min_pos = -1
			cur = 0
			for i in range(n):
				s += arr[i]
				cur = s - min_s
				if cur > ans:
					ans = cur
					ans_l = min_pos + 1
					ans_r = i
				if s < min_s:
					min_s = s
					min_pos = i
			if ans >= t and ans_l != 0 and (ans_r != n - 1):
				print('NO')
			else:
				print('YES')


def maxSubArraySum(a, size):
	max_so_far = -1000000009
	max_ending_here = 0
	for i in range(0, size - 1):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def maxSubArraySum1(a, size):
	max_so_far = -1000000009
	max_ending_here = 0
	for i in range(1, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	ya = sum(arr)
	ad1 = maxSubArraySum(arr, len(arr))
	ad2 = maxSubArraySum1(arr, len(arr))
	if ad1 > ad2:
		ad = ad1
	else:
		ad = ad2
	if ya > ad:
		print('YES')
	else:
		print('NO')


def isYasserHappy(n, s):
	left_sum = 0
	for element in s:
		left_sum += element
		if left_sum <= 0:
			return False
	right_sum = 0
	for element in reversed(s):
		right_sum += element
		if right_sum <= 0:
			return False
	return True

def solve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		print('YES' if isYasserHappy(n, s) else 'NO')
solve()


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
for _ in range(int(input())):
	input()
	l = list(map(int, input().split()))
	summ = sum(l)
	k = maxSubArraySum(l[:-1], len(l) - 1)
	p = maxSubArraySum(l[1:], len(l) - 1)
	k = max(p, k)
	if summ > k:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
ans_arr = []
for x in range(t):
	n = int(sys.stdin.readline())
	a = [int(y) for y in sys.stdin.readline().split()]
	yasser = sum(a)
	pre_arr = []
	for g in range(n):
		if g == 0:
			pre_arr.append(a[g])
		else:
			pre_arr.append(a[g] + pre_arr[g - 1])
	adel = -pow(10, 9) - 10
	arr = [pow(10, 9) + 10] * n
	for g in range(n):
		if g == 0:
			arr[g] = min(0, arr[g])
		else:
			arr[g] = min(arr[g], arr[g - 1])
	for h in range(n - 1):
		adel = max(pre_arr[h] - arr[h], adel)
	for p in range(1, n):
		adel = max(adel, pre_arr[n - 1] - pre_arr[p - 1])
	adel = max(adel, 0)
	if adel < yasser:
		ans_arr.append('YES')
	else:
		ans_arr.append('NO')
print('\n'.join(ans_arr))


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	SUM = 0
	for i in range(n):
		SUM += a[i]
	bpref = 0
	bsum = -1000000000000000
	nsum = 0
	c = 0
	for i in range(n - 1):
		nsum += a[i]
		bsum = max(bsum, nsum - bpref)
		bpref = min(nsum, bpref)
		if nsum == 0:
			c += 1
	if bpref != 0 or c > 0:
		bsum = max(bsum, SUM - bpref)
	if bsum >= SUM:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	done = 0
	s = list(map(int, input().split()))
	right = [0] * len(s)
	left = [0] * len(s)
	prev = 0
	for i in range(len(s)):
		right[i] = prev + s[i]
		prev = right[i]
		if right[i] <= 0:
			print('NO')
			done = 1
			break
	prev = 0
	if not done:
		for i in reversed(range(len(s))):
			left[i] = prev + s[i]
			prev = left[i]
			if left[i] <= 0:
				print('NO')
				done = 1
				break
	if not done:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	count = 0
	p = 0
	a = [*map(int, input().split())]
	l = list(a)
	b = 0
	c = 0
	for i in range(0, n - 1):
		b = b + a[i]
		c = c + a[n - i - 1]
		if b < 1 or c < 1:
			print('NO')
			break
	else:
		print('YES')


import sys
t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	(mi, maxsum, tot, pre) = (0, 0, 0, 0)
	for i in range(0, n - 1):
		tot += a[i]
		pre = max(0, pre + a[i])
		maxsum = max(maxsum, pre)
	tot += a[n - 1]
	pre = 0
	for i in range(0, n):
		pre += a[i]
		maxsum = max(maxsum, tot - pre)
	if tot > maxsum:
		print('YES')
	else:
		print('NO')


out = ''
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	right_sum = 0
	left_sum = 0
	result = 'YES'
	for j in range(n):
		k = n - j - 1
		left_sum += a[j]
		right_sum += a[k]
		if left_sum <= 0 or right_sum <= 0:
			result = 'NO'
			break
	out += result + '\n'
print(out, end='')


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	(flag1, flag2) = (1, 1)
	sumo = 0
	for i in array:
		sumo += i
		if sumo <= 0:
			flag1 = 0
			break
	sumo = 0
	for i in array[::-1]:
		sumo += i
		if sumo <= 0:
			flag2 = 0
			break
	if flag1 == 0 or flag2 == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	d = 0
	a = list(map(int, input().strip().split()))
	y = sum(a)
	e = []
	w = []
	r = 0
	for i in range(n - 1):
		d += a[i]
		if d <= 0 or d >= y:
			r = 1
			print('NO')
			break
	if r == 0:
		print('YES')


q = int(input())
for re in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	pref = [0] * n
	pref[0] = l[0]
	for i in range(1, n):
		pref[i] = pref[i - 1] + l[i]
	prefr = [0] * n
	prefr[0] = l[n - 1]
	for i in range(1, n):
		prefr[i] = prefr[i - 1] + l[n - i - 1]
	odp = 1
	for i in range(n):
		if prefr[i] <= 0:
			odp = 0
			break
	for i in range(n):
		if pref[i] <= 0:
			odp = 0
			break
	if odp:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from collections import deque
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def MA(l):
	ma = float('-inf')
	n = len(l)
	a = 0
	for i in range(n):
		a += l[i]
		if a > ma:
			ma = a
		if a < 0:
			a = 0
	return ma

def solve():
	n = inp()
	l = li()
	s = sum(l)
	if s > max(MA(l[:-1]), MA(l[1:])):
		print('YES')
	else:
		print('NO')
for _ in range(inp()):
	solve()


def maxSum(arr, l, r):
	sum = 0
	maxSum = 0
	for idx in range(l, r + 1):
		sum += arr[idx]
		maxSum = max(maxSum, sum)
		if sum < 0:
			sum = 0
	return maxSum
T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	Yasser = 0
	for no in arr:
		Yasser += no
	Adel = max(maxSum(arr, 0, n - 2), maxSum(arr, 1, n - 1))
	if Yasser > Adel:
		print('YES')
	else:
		print('NO')


def cal(array):
	res = array[0]
	sum = array[0]
	Min = min(0, array[0])
	array = array[1:]
	for a in array:
		sum += a
		res = max(res, sum - Min)
		Min = min(Min, sum)
	return res
t = int(input())
while t > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	array1 = a[1:]
	array2 = a[:n - 1]
	sum0 = 0
	for i in a:
		sum0 += i
	sum1 = cal(array1)
	sum2 = cal(array2)
	if sum1 < sum0 and sum2 < sum0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for j in range(t):
	n = int(input())
	sz = [int(x) for x in input().split()]
	a = sum(sz)
	ans1 = -100000
	cnt = 0
	for i in range(1, n):
		cnt += sz[i]
		ans1 = max(ans1, cnt)
		if cnt < 0:
			cnt = 0
	ans2 = -100000
	cnt = 0
	for i in range(0, n - 1):
		cnt += sz[i]
		ans2 = max(ans2, cnt)
		if cnt < 0:
			cnt = 0
	if a > max(ans1, ans2):
		print('YES')
		continue
	else:
		print('NO')
		continue


ans = []
for i in range(int(input())):
	n = int(input())
	nums = input().split()
	s = 0
	for i in range(n):
		nums[i] = int(nums[i])
		s += nums[i]
	(m, current) = (0, 0)
	for i in nums[0:-1]:
		if current + i > 0:
			current += i
		else:
			current = 0
		if current > m:
			m = current
	current = 0
	for i in nums[1:]:
		if current + i > 0:
			current += i
		else:
			current = 0
		if current > m:
			m = current
	if s > m:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


for _ in range(int(input())):
	i = int(input())
	l = list(map(int, input().split()))
	ans = 'YES'
	c = 0
	for x in l:
		c += x
		if c <= 0:
			ans = 'NO'
	c = 0
	for x in l[::-1]:
		c += x
		if c <= 0:
			ans = 'NO'
	print(ans)


n = int(input())
for _ in range(n):
	m = int(input())
	a = [0] + [int(x) for x in input().split(' ')]
	gbl_sum = 0
	lcl_sum = 0
	(r, l, d) = (0, 0, 0)
	for i in range(m + 1):
		lcl_sum += a[i]
		if lcl_sum <= 0:
			lcl_sum = 0
			r = i
		if gbl_sum < lcl_sum:
			gbl_sum = lcl_sum
			l = i
			d = max(d, l - r)
	if gbl_sum >= sum(a) and d < m:
		print('NO')
	else:
		print('YES')


def kadane(a, n, s):
	max_so_far = 0
	l = 0
	for i in range(n):
		if max_so_far + a[i] >= s:
			l += 1
			return l
		if max_so_far + a[i] > 0:
			max_so_far += a[i]
			l += 1
		else:
			max_so_far = 0
			l = 0
	return l
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a)
	l = kadane(a, n, y)
	if l == n:
		print('YES')
	else:
		print('NO')


dl = int(input())
for i in range(dl):
	l1 = int(input())
	arr = [int(i) for i in filter(None, input().split(' '))]
	t = 0
	l = 0
	r = l1 - 1
	sym = 0
	while l != l1 - 1:
		sym += arr[l]
		if sym <= 0:
			t = 1
		l += 1
	sym = 0
	while r != 0:
		sym += arr[r]
		if sym <= 0:
			t = 1
		r -= 1
	sym = 0
	if t == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	top = 0
	su = 0
	for i in range(n - 1):
		su = max(l[i] + su, l[i])
		top = max(top, su)
	top1 = 0
	su1 = 0
	for i in range(1, n):
		su1 = max(l[i] + su1, l[i])
		top1 = max(top1, su1)
	top = max(top, top1)
	if top >= sum(l):
		print('NO')
	else:
		print('YES')


def solution(test):
	sum = 0
	for i in test:
		sum += i
		if sum <= 0:
			print('NO')
			return
	sum = 0
	for i in reversed(test):
		sum += i
		if sum <= 0:
			print('NO')
			return
	print('YES')
test_case = int(input())
test_input = []
for i in range(test_case):
	n = int(input())
	ar = [int(x) for x in input().split()]
	test_input.append(ar)
for test in test_input:
	solution(test)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s1 = sum(a)
	s = 0
	f = 0
	k = 0
	m = 0
	for (j, i) in enumerate(a):
		s += i
		if s <= 0:
			f = 1
			s = 0
		m = max(m, s)
		if m >= s1:
			if f == 1 or j != n - 1:
				print('NO')
				k = 1
				break
	if k != 1:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s1 = sum(l)
	c = 0
	f = 0
	s2 = 0
	for i in range(n - 1):
		s2 += l[i]
		if s2 <= 0:
			s2 = 0
			c = 1
		if s2 >= s1:
			f = 1
			break
	if f != 1:
		s3 = 0
		if c == 1:
			s3 = s2 + l[-1]
		elif l[-1] > 0 and l[0] > 0 and (c == 0):
			s3 = s2 + l[-1] - l[0]
		if s3 >= s1:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


from itertools import accumulate
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	(l, r) = (0, 0)
	ans = 'YES'
	for i in range(n - 1):
		l += a[i]
		r += a[-i - 1]
		if l <= 0 or r <= 0:
			ans = 'NO'
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dp1 = [a[0]]
	flag = False
	for i in range(1, n - 1):
		dp1.append(max(a[i], dp1[i - 1] + a[i]))
	dp2 = [a[1]]
	for i in range(2, n):
		dp2.append(max(a[i], dp2[i - 2] + a[i]))
	s = sum(a)
	if max(dp1 + dp2) < s:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	s = 0
	flag = False
	for i in range(n):
		s += A[i]
		if s <= 0:
			flag = True
	s = 0
	for i in reversed(range(n)):
		s += A[i]
		if s <= 0:
			flag = True
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ys = sum(a)
	msf = a[0]
	cm = a[0]
	for i in range(1, n - 1):
		cm = max(a[i], cm + a[i])
		msf = max(msf, cm)
	a = a[::-1]
	msf1 = a[0]
	cm1 = a[0]
	for i in range(1, n - 1):
		cm1 = max(a[i], cm1 + a[i])
		msf1 = max(msf1, cm1)
	adel = max(msf, msf1)
	if ys > adel:
		print('YES')
	else:
		print('NO')


t = int(input())
for loop in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	flag = True
	now = 0
	for i in range(n - 1):
		now += a[i]
		if now >= s or s - now >= s:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	sum = 0
	for i in a:
		sum += i
		if sum <= 0:
			flag = False
			break
	a.reverse()
	sum = 0
	for i in a:
		sum += i
		if sum <= 0:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		ok = True
		t = 0
		for c in a:
			t += c
			if t <= 0:
				ok = False
		t = 0
		for c in a[::-1]:
			t += c
			if t <= 0:
				ok = False
		rr.append(YES(ok))
	return JA(rr, '\n')
print(main())


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class SegTree:

	def __init__(self, n, func, intv, A=[]):
		self.n = n
		self.func = func
		self.intv = intv
		n2 = 1
		while n2 < n:
			n2 <<= 1
		self.n2 = n2
		self.tree = [self.intv] * (n2 << 1)
		if A:
			for i in range(n):
				self.tree[n2 + i] = A[i]
			for i in range(n2 - 1, -1, -1):
				self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def update(self, i, x):
		i += self.n2
		self.tree[i] = x
		while i > 0:
			i >>= 1
			self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def query(self, a, b):
		l = a + self.n2
		r = b + self.n2
		s = self.intv
		while l < r:
			if r & 1:
				r -= 1
				s = self.func(s, self.tree[r])
			if l & 1:
				s = self.func(s, self.tree[l])
				l += 1
			l >>= 1
			r >>= 1
		return s

	def get(self, i):
		return self.tree[i + self.n2]

	def all(self):
		return self.tree[1]
for _ in range(INT()):
	N = INT()
	A = LIST()
	x = sum(A)
	acc = [0] + list(accumulate(A))
	st = SegTree(N + 1, max, -INF, acc)
	y = st.query(1, N)
	for i in range(1, N):
		y = max(y, st.query(i + 1, N + 1) - st.get(i))
	if x > y:
		YES()
	else:
		NO()


from os import truncate
for s in [*open(0)][2::2]:
	a = [*map(int, s.split())]
	sz = len(a)
	sm = [0] * sz
	cur_sm = 0
	got = False
	for (i, x) in enumerate(a):
		cur_sm += x
		if i == sz - 1:
			break
		if cur_sm <= 0:
			print('NO')
			got = True
			break
	if got:
		continue
	cur_sm = 0
	for (i, x) in enumerate(a[::-1]):
		cur_sm += x
		if i == sz - 1:
			break
		if cur_sm <= 0:
			print('NO')
			got = True
			break
	if got:
		continue
	print('YES')


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	sm1 = 0
	sm2 = 0
	f = True
	for i in range(n):
		sm1 += l[i]
		sm2 += l[n - i - 1]
		if sm1 <= 0 or sm2 <= 0:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


import sys
from bisect import bisect_left as bl, bisect_right as br, bisect
import math
from itertools import zip_longest as zl
from itertools import groupby as gb
from itertools import combinations as comb
from itertools import combinations_with_replacement as cwr
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter as c
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return input()

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]

def kadane(a, size):
	max_so_far = -pow(10, 9) - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for _ in range(int(data())):
	n = int(data())
	arr = l()
	cnt = 0
	for i in arr:
		if i < 0:
			cnt += 1
	if kadane(arr[1:], n - 1) >= sum(arr) or kadane(arr[:n - 1], n - 1) >= sum(arr):
		print('NO')
	else:
		print('YES')


def find_negative(array):
	add = 0
	for i in array:
		add += i
		if add <= 0:
			return False
	return True
t = int(input())
n_list = []
cake_list = []
for i in range(t):
	n_list.append(int(input()))
	cake_list.append(list(map(int, input().split())))
for i in range(t):
	n = n_list[i]
	cake = cake_list[i]
	res_1 = find_negative(cake)
	if not res_1:
		print('NO')
	elif res_1:
		cake.reverse()
		res_2 = find_negative(cake)
		if not res_2:
			print('NO')
		elif res_2:
			print('YES')


def maSaSum(a, l, r):
	max_so_far = 0
	max_ending_here = 0
	for i in range(l, r):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	yasser = sum(a)
	alen1 = maSaSum(a, 0, n - 1)
	alen2 = maSaSum(a, 1, n)
	alen = max(alen1, alen2)
	if yasser <= alen:
		print('NO')
	else:
		print('YES')


def arr_inp():
	return [int(x) for x in stdin.readline().split()]

def check():
	s = 0
	for i in a:
		s += i
		if s <= 0:
			return 'NO'
	s = 0
	for i in a[::-1]:
		s += i
		if s <= 0:
			return 'NO'
	return 'YES'
from sys import stdin
for i in range(int(input())):
	(n, a) = (int(input()), arr_inp())
	print(check())


from __future__ import print_function
import sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true = True
false = False
null = None
SLOW = True
try:
	range = xrange
except:
	ignored = 1

def fast():
	global SLOW
	SLOW = False

def compute(val, func):
	return func(val)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return '{0:.{1}f}'.format(val, nd)

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def e1e(d, e):
	return d * 10 ** e
mod = e1e(1, 9) + 7
try:
	memoi = functools.lru_cache(None)
except:

	class memoize(dict):

		def __init__(self, f):
			self.f = f

		def __call__(self, *args):
			return self[args]

		def __missing__(self, key):
			ans = self[key] = self.f(*key)
			return ans
	memoi = memoize

class ndarray(list):

	def __init__(self, defval, sizes):
		self.sizes = sizes
		self.dimension = len(sizes)
		self.pm = pm = list(sizes)
		pm.append(1)
		for ii in reversed(range(self.dimension)):
			pm[ii] *= pm[ii + 1]
		list.__init__(self, [defval] * pm[0])

	def ___i1d___(self, ixs):
		if len(ixs) != self.dimension:
			raise LookupError('Dimension must be {}.'.format(self.dimension))
		ans = 0
		for ii in range(self.dimension):
			ix = ixs[ii]
			if ix >= self.sizes[ii]:
				raise IndexError('Index[{}]={} >= Len[{}]={}.'.format(ii, ix, ii, self.sizes[ii]))
			ans += ix * self.pm[ii + 1]
		return ans

	def __getitem__(self, ixs):
		ixs = self.___i1d___(ixs)
		return list.__getitem__(self, ixs)

	def __setitem__(self, ixs, val):
		ixs = self.___i1d___(ixs)
		list.__setitem__(self, ixs, val)

	def _str_(self, dim0=0, ofs=0):
		lft = '  ' * dim0
		if dim0 + 1 == self.dimension:
			return lft + str(list.__getitem__(self, slice(ofs, ofs + self.sizes[dim0])))
		ans = []
		for ii in range(self.sizes[dim0]):
			ans.append(self._str_(dim0 + 1, ofs))
			ofs += self.pm[dim0 + 1]
		ans = '{0}[\n{1}\n{0}]'.format(lft, ',\n'.join(ans))
		return ans

	def __str__(self):
		return self._str_()

def arrays(defval, *sizes):
	if len(sizes) == 1:
		return [defval] * sizes[0]
	return ndarray(defval, sizes)

def perr(*args, **kwargs):
	if SLOW:
		print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

def lines(n):
	return [line() for i in range(n)]

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
		elif isinstance(o, str):
			o = split(o)
	return list(map(num, o or split()))

def loop(f, n=99999999):
	for tcid in range(n):
		f(tcid + 1)

def mainloop(tcid):
	ignored = 1

	def solve():
		ignored = 2
		n = num()
		a = nums()
		mval = a[0]
		mseg = (0, 1)
		sums = 0
		lfts = 0
		for ii in range(n):
			aa = a[ii]
			sums += aa
			if sums > mval:
				mval = sums
				mseg = (lfts, ii + 1)
			elif sums == mval:
				mseg = (lfts, mseg[1])
			if sums <= 0:
				sums = 0
				lfts = ii + 1
		return int(mseg == (0, n))
	ans = solve()
	ans = ['NO', 'YES'][ans]
	print(ans)
loop(mainloop, num())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	maxx = sum(arr)
	if maxx <= max(arr):
		print('NO')
	else:
		v = True
		dp = [[maxx] for i in range(n)]
		c = 0
		for i in range(0, n):
			j = n - 1
			if j - i + 1 != n:
				x = dp[i][-1] - c
				if x >= maxx:
					print('NO')
					v = False
					break
				else:
					dp[i].append(x)
			else:
				for j in range(n - 1, i, -1):
					x = dp[i][-1] - arr[j] - c
					if x >= maxx:
						print('NO')
						v = False
						break
					else:
						dp[i].append(x)
			if not v:
				break
			c += arr[i]
		if v:
			print('YES')


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] <= val:
			ans = mid + 1
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split(' ')))
	max1 = 0
	max2 = 0
	i1 = 1
	i2 = 1
	l1 = []
	l2 = []
	max3 = sum(l)
	for i in range(n):
		max2 += l[i]
		if max2 <= 0:
			max2 = 0
			i1 = i + 1
			i2 = i + 1
		if max2 >= max1:
			max1 = max2
			i2 = i + 1
			if max1 == max3:
				l1.append(i1)
				l2.append(i2)
	if max3 > max1:
		print('YES')
	elif max3 == max1:
		boo = True
		for i in range(len(l1)):
			if l1[i] != 1 or l2[i] != n:
				boo = False
				break
		if boo:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	l = 0
	r = 0
	flag = 0
	for i in range(n):
		l += arr[i]
		r += arr[n - i - 1]
		if l <= 0 or r <= 0:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	s1 = s[1:]
	s2 = s[:len(s) - 1]
	ans1 = s1[0]
	ans2 = s1[0]
	for i in range(1, len(s1)):
		ans2 = max(s1[i], s1[i] + ans2)
		ans1 = max(ans1, ans2)
	ans4 = s2[0]
	ans5 = s2[0]
	for i in range(1, len(s2)):
		ans5 = max(s2[i], s2[i] + ans5)
		ans4 = max(ans4, ans5)
	ans3 = 0
	for i in range(0, len(s)):
		ans3 += s[i]
	if ans3 > ans1 and ans3 > ans4:
		print('YES')
	else:
		print('NO')


def fn(a):
	s = 0
	for i in range(n):
		s += a[i]
		if s <= 0:
			return False
	s = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s <= 0:
			return False
	return True
t = int(input())
for w in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if fn(a):
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	total = sum(a)
	acc = [0] * (n + 1)
	for i in range(n):
		acc[i + 1] += acc[i] + a[i]
	max_r = [0] * (n + 1)
	for i in range(n, 0, -1):
		if acc[i] > max_r[i]:
			max_r[i] = acc[i]
		max_r[i - 1] = max_r[i]
	max_r[1] = max(acc[:-1])
	max_sub = -10 ** 18
	for i in range(n):
		if max_sub < max_r[i + 1] - acc[i]:
			max_sub = max_r[i + 1] - acc[i]
	print('YES' if max_sub < total else 'NO')


import sys
import math
import bisect
import re

def main():
	for _ in range(int(input())):
		n = int(input())
		A = list(map(int, input().split()))
		B = A.copy()
		C = A.copy()
		for i in range(1, n):
			B[i] += B[i - 1]
		for i in range(n - 2, -1, -1):
			C[i] += C[i + 1]
		ans = True
		for i in range(n - 1):
			if B[i] <= 0:
				ans = False
		for i in range(n - 1, 0, -1):
			if C[i] <= 0:
				ans = False
		if ans:
			print('YES')
		else:
			print('NO')
main()


get_int = lambda : int(input())
get_mul_int = lambda : map(int, input().rstrip().split())
get_list = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	n = get_int()
	a = get_list()
	front = rear = 0
	for i in range(n - 1):
		front += a[i]
		rear += a[n - i - 1]
		if rear < 1 or front < 1:
			print('NO')
			return
	print('YES')
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 1
	sum = 0
	for i in range(n):
		sum += l[i]
		if sum <= 0:
			flag = 0
			break
	sumi = 0
	for j in range(n - 1, -1, -1):
		sumi += l[j]
		if sumi <= 0:
			flag = 0
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maxlast = 0
	maxbest = 0
	count = 1
	for x in arr[1:]:
		maxlast = max(maxlast + x, x)
		maxbest = max(maxbest, maxlast)
	maxlast = 0
	for x in arr[:-1]:
		maxlast = max(maxlast + x, x)
		maxbest = max(maxbest, maxlast)
	if sum(arr) > maxbest:
		print('YES')
	else:
		print('NO')


def C(a):
	ans = 0
	cur = 0
	for i in a:
		cur = max(cur + i, 0)
		ans = max(ans, cur)
	return ans
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	x = max(C(a[:n - 1]), C(a[1:]))
	if x >= sum(a):
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	total = sum(arr)
	s = 0
	flag = True
	for i in range(n - 1):
		s += arr[i]
		if s >= total or s <= 0:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def kadane(arr):
	maxoverall = -10 ** 9
	maxtillhere = 0
	for x in arr:
		maxtillhere += x
		if maxtillhere < 0:
			maxtillhere = 0
		if maxoverall < maxtillhere:
			maxoverall = maxtillhere
	return maxoverall

def program():
	n = int(input())
	l = list(map(int, input().split()))
	total = sum(l)
	if total > max(kadane(l[0:n - 1]), kadane(l[1:n])):
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	program()


a = int(input())
for i in range(a):
	b = int(input())
	summ = 0
	array = list(map(int, input().split()))
	max_sum = [0]
	max_sum1 = [0]
	for x in range(len(array) - 1):
		tmp = max_sum[-1] + array[x]
		if tmp < 0:
			tmp = 0
		max_sum.append(tmp)
	for x in range(1, len(array)):
		tmp1 = max_sum1[-1] + array[x]
		if tmp1 < 0:
			tmp1 = 0
		max_sum1.append(tmp1)
	for i in range(len(array)):
		summ += array[i]
	maxx = max(max(max_sum), max(max_sum1))
	if summ > maxx:
		print('YES')
	else:
		print('NO')


def will_yasser_be_happy(cupcakes_tastiness):
	number_of_cupcakes = len(cupcakes_tastiness)
	max_column = 0
	max_tastiness = cupcakes_tastiness[0]
	tastiness = [cupcakes_tastiness[0]]
	for i in range(1, number_of_cupcakes):
		previous_tastiness = tastiness[i - 1]
		current_tastiness = cupcakes_tastiness[i] + previous_tastiness
		tastiness.append(current_tastiness)
		if current_tastiness > max_tastiness and i < number_of_cupcakes - 1:
			max_tastiness = current_tastiness
			max_column = i
	yasser_tastiness = tastiness[i]
	if max_tastiness >= yasser_tastiness:
		return 'NO'
	new_max = 0
	new_tastiness = []
	new_tastiness.append(tastiness[i])
	for i in range(1, number_of_cupcakes):
		previous_tastiness = new_tastiness[i - 1]
		current_tastiness = new_tastiness[i - 1] - cupcakes_tastiness[i - 1]
		new_tastiness.append(current_tastiness)
		if current_tastiness >= yasser_tastiness:
			return 'NO'
	return 'YES'
test_cases = int(input())
responses = []
for i in range(0, test_cases):
	cupcakes = int(input())
	cupcakes_tastiness = [int(i) for i in input().split()]
	responses.append(will_yasser_be_happy(cupcakes_tastiness))
for response in responses:
	print(response)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	input()
	l = list(map(int, input().split()))
	bad = False
	curr = 0
	for v in l:
		curr += v
		if curr <= 0:
			bad = True
			break
	l.reverse()
	curr = 0
	for v in l:
		curr += v
		if curr <= 0:
			bad = True
			break
	if bad:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	flag = True
	sum = 0
	for i in arr:
		sum += i
		if sum <= 0:
			print('NO')
			flag = False
			break
	if flag:
		sum = 0
		for i in arr[::-1]:
			sum += i
			if sum <= 0:
				print('NO')
				flag = False
				break
	if flag:
		print('YES')


for t in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	pre_sum = [0]
	for i in range(n):
		pre_sum.append(pre_sum[i] + l[i])
	m = []
	mc = pre_sum[0]
	for i in range(1, n + 1):
		if mc > pre_sum[i - 1]:
			mc = pre_sum[i - 1]
		m.append(mc)
	ch = pre_sum[n]
	for i in range(1, n + 1):
		if ch < pre_sum[i] - m[i - 1]:
			print('NO')
			break
		elif ch == pre_sum[i] - m[i - 1]:
			if i == n and pre_sum.count(0) == 1:
				continue
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	s = sum(a)
	k1 = a[0]
	k2 = s - a[0]
	for i in range(1, n):
		if k1 <= 0 or k2 <= 0:
			print('NO')
			break
		k1 += a[i]
		k2 -= a[i]
	else:
		print('YES')


def maxSubArraySum(a, size):
	maxint = 1000000000
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = maxSubArraySum(l[:-1], n - 1)
	b = maxSubArraySum(l[1:], n - 1)
	if a < b:
		a = b
	s = sum(l)
	if s > a:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	yas = sum(a)
	total = list()
	start = 0
	for i in range(n):
		if i == 0:
			total.append(max(a[0], 0))
			if a[0] < 0:
				start = 1
		else:
			h = total[-1] + a[i]
			if h <= 0:
				start = i + 1
			total.append(max(0, h))
	flag = 0
	if start == 0 and yas == total[-1]:
		flag = 0
	if start == 0:
		g = n - 1
	else:
		g = n
	for i in range(g):
		if total[i] >= yas:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = gil()
	b = a[:]
	base = sum(a)
	b[0] = a[-1] = 0
	other = a[0]
	for i in range(1, n):
		a[i] = max(a[i], a[i] + a[i - 1])
		b[i] = max(b[i], b[i] + b[i - 1])
		other = max(b[i], a[i], other)
	print('YES' if base > other else 'NO')


def check(a, n):
	ssum = 0
	for i in range(n):
		ssum += a[i]
		if ssum <= 0:
			return True
	ssum = 0
	for i in range(n - 1, -1, -1):
		ssum += a[i]
		if ssum <= 0:
			return True
	return False
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = check(a, n)
	if res:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	_max = 0
	csum = 0
	tsum = sum(a)
	for i in range(0, n - 1):
		csum += a[i]
		if csum < 0:
			csum = 0
		_max = max(_max, csum)
	csum2 = 0
	for i in range(1, n):
		csum2 += a[i]
		if csum2 < 0:
			csum2 = 0
		_max = max(_max, csum2)
	if _max >= tsum:
		print('NO')
	else:
		print('YES')


t = int(input())

def solve():
	s = 0
	for i in range(n):
		s += a[i]
		if s <= 0:
			return False
	s = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s <= 0:
			return False
	return True
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
for awfdhguwa in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cmax = 0
	clen = 0
	s = 0
	m = 0
	for i in a:
		s += i
	for i in range(1, n):
		if cmax > 0:
			clen += 1
			cmax += a[i]
		else:
			clen = 1
			cmax = a[i]
		if cmax > m:
			m = cmax
	cmax = 0
	clen = 0
	for i in range(n - 1):
		if cmax > 0:
			clen += 1
			cmax += a[i]
		else:
			clen = 1
			cmax = a[i]
		if cmax > m:
			m = cmax
	if s > m:
		print('YES')
	else:
		print('NO')


def kadane(a, l, r):
	sum = 0
	ans = 0
	for x in range(l, r):
		sum += a[x]
		ans = max(ans, sum)
		if sum < 0:
			sum = 0
	return ans

def solve():
	m = int(input())
	sum = 0
	a = [int(a) for a in input().split()]
	for x in range(0, len(a)):
		sum += a[x]
	k1 = kadane(a, 0, len(a) - 1)
	k2 = kadane(a, 1, len(a))
	if max(k1, k2) >= sum:
		print('NO')
	else:
		print('YES')
n = int(input())
while n != 0:
	solve()
	n = n - 1


import math
from decimal import *
import random
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	f = sum(arr)
	dif = []
	(max_far, max_end) = (0, 0)
	for i in range(1, n):
		max_end += arr[i]
		if max_end > max_far:
			max_far = int(max_end)
		if max_end < 0:
			max_end = 0
	dif.append(max_far)
	(max_far, max_end) = (0, 0)
	for i in range(0, n - 1):
		max_end += arr[i]
		if max_end > max_far:
			max_far = int(max_end)
		if max_end < 0:
			max_end = 0
	dif.append(max_far)
	if max(dif) >= f:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout

def submax_0(A):
	I = J = None
	msum = -464664554765454
	running_sum = 0
	running_sum_start = 0
	for i in range(len(A)):
		if running_sum < 0:
			running_sum = 0
			running_sum_start = i
		running_sum += A[i]
		if running_sum >= msum:
			msum = running_sum
			I = running_sum_start
			J = i
	return (I, J, msum)
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	cc = list(map(int, stdin.readline().split()))
	Y = sum(cc)
	A = [submax_0(cc), submax_0(cc[1:]), submax_0(cc[:-1])]
	A.sort(key=lambda x: x[2], reverse=True)
	Apeak = A[0][2]
	usefulA = [Ai for Ai in A if Ai[2] == Apeak]
	if any(map(lambda a: a[2] >= Y and (not (1, n) == (a[0] + 1, a[1] + 1)), usefulA)):
		stdout.write('NO\n')
	else:
		stdout.write('YES\n')


from sys import stdin, stdout
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x * (x + 1) // 2
I = lambda x: 1 + 2 * x
R = lambda : stdin.readline()
Ri = lambda x: map(int, x.split())
Rs = lambda x: map(str, x.split())
Rf = lambda x: map(float, x.split())

def main():
	t = int(R())
	for test in range(t):
		n = int(R())
		A = list(Ri(R()))
		(a, b, c, bb, cc) = (sum(A), 0, 0, 0, 0)
		for i in range(1, n):
			b += A[i - 1]
			bb = max(b, bb)
			b = max(b, 0)
			c += A[i]
			cc = max(c, cc)
			c = max(c, 0)
		b = max(bb, cc)
		if a > b:
			Pi('YES')
		else:
			Pi('NO')
main()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	t_y = sum(arr)
	pre_arr = [0, arr[0]]
	for i in range(1, n - 1):
		pre_arr.append(pre_arr[-1] + arr[i])
	suff_arr = [0, arr[-1]]
	for i in range(n - 2, 0, -1):
		suff_arr.append(suff_arr[-1] + arr[i])
	mini = min(suff_arr[1:n])
	suff_min = [0]
	for i in range(1, n):
		if suff_arr[i] < suff_min[-1]:
			suff_min.append(suff_arr[i])
		else:
			suff_min.append(suff_min[-1])
	for i in range(1, n):
		temp = suff_min[n - i - 1] + pre_arr[i]
		if temp < mini:
			mini = temp
	if mini <= 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	t = int(input())
	pies = list(map(int, input().split(' ')))
	flag = True
	tmp_sum = 0
	for j in range(len(pies)):
		tmp_sum += pies[j]
		if tmp_sum <= 0:
			print('NO')
			flag = False
			break
	if flag != False:
		tmp_sum = 0
		for j in range(len(pies) - 1, 0, -1):
			tmp_sum += pies[j]
			if tmp_sum <= 0:
				print('NO')
				flag = False
				break
	if flag != False:
		print('YES')


def de(s, n):
	n -= 1
	max_local = 0
	max_global = 0
	for i in range(n):
		if max_local + s[i] < 0:
			max_local = 0
		else:
			max_local += s[i]
		max_global = max(max_local, max_global)
	return max_global
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	yasser = sum(a)
	adel = max(de(a[1:], n), de(a[:n - 1], n))
	if yasser > adel:
		print('YES')
	else:
		print('NO')


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(s1, s2) = (0, 0)
	res = 'YES'
	for i in range(n - 1):
		s1 += a[i]
		s2 += a[-i - 1]
		if s1 <= 0 or s2 <= 0:
			res = 'NO'
			break
	print(res)


for i in [0] * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	sum = 0
	f = True
	for i in a:
		sum += i
		if sum <= 0:
			print('NO')
			f = False
			break
	if f == True:
		sum = 0
		for i in a[::-1]:
			sum += i
			if sum <= 0:
				print('NO')
				f = False
				break
	if f == True:
		print('YES')


t = int(input())
itog = []
for f in range(t):
	n = int(input())
	mass = [0] + list(map(int, input().split()))
	yasser = sum(mass)
	adel = 0
	for i in range(1, n + 1):
		if mass[i] >= yasser:
			adel += 1
			break
		else:
			mass[i] += mass[i - 1]
			if i == n:
				continue
			elif mass[i] >= yasser:
				adel += 1
				break
	mass.sort()
	mass = mass[1:]
	if mass[-1] - mass[0] >= yasser:
		adel += 1
	if adel > 0:
		itog.append('NO')
	else:
		itog.append('YES')
for i in itog:
	print(i)


import math
debug = False

def pprint(*args, delimiter='#', amount=10):
	if debug:
		print('{0} DEBUG {0}'.format(delimiter * amount))
		print(*args)
		print('{0} ----- {0}'.format('-' * amount))

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	summ = sum(a)
	if a[0] < 0 or a[-1] < 0:
		return 'NO'
	current_sum = 0
	ans_left = a[0]
	for i in range(n - 1):
		current_sum += a[i]
		ans_left = max(ans_left, current_sum)
		current_sum = max(0, current_sum)
	current_sum = 0
	ans_right = a[1]
	for i in range(1, n):
		current_sum += a[i]
		ans_right = max(ans_right, current_sum)
		current_sum = max(0, current_sum)
	pprint(ans_left, ans_right)
	if max(ans_left, ans_right) >= summ:
		return 'NO'
	return 'YES'
t = int(input())
while t > 0:
	t -= 1
	print(solve())


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	k = m[0]
	j = m[n - 1]
	a = b = 0
	r = 'YES'
	for i in range(n - 1):
		a += m[i]
		b += m[n - 1 - i]
		if a <= 0 or b <= 0:
			r = 'NO'
			break
	print(r)


from math import *
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = 100000009

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def maxSubArraySum(a, size):
	max_so_far_1 = a[0]
	curr_max_1 = a[0]
	max_so_far_2 = a[1]
	curr_max_2 = a[1]
	for i in range(1, size - 1):
		curr_max_1 = max(a[i], curr_max_1 + a[i])
		max_so_far_1 = max(max_so_far_1, curr_max_1)
	for i in range(2, size):
		curr_max_2 = max(a[i], curr_max_2 + a[i])
		max_so_far_2 = max(max_so_far_2, curr_max_2)
	return max(max_so_far_1, max_so_far_2)
for _ in range(int(input())):
	n = int(input())
	l = li()
	s = sum(l)
	t = maxSubArraySum(l, n)
	if s > t:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if a[0] <= 0 or a[n - 1] <= 0:
		print('NO')
		continue
	sum = 0
	ans = 0
	flag = 0
	dp = []
	k = 0
	for i in range(0, n):
		sum += a[i]
		dp.append(0)
		if i == 0:
			dp[i] = max(0, a[i])
		elif dp[i - 1] + a[i] > dp[i]:
			dp[i] = dp[i - 1] + a[i]
		else:
			flag = 1
		if dp[i] > ans:
			k = i
			ans = dp[i]
	if flag == 0 and k == n - 1 and (sum == ans) or sum > ans:
		print('YES')
	else:
		print('NO')


from sys import stdin, setrecursionlimit

def input():
	return stdin.readline().strip()
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	total = sum(arr)
	length = 0
	pre_sum = 0
	for i in range(n):
		if arr[i] + pre_sum > 0:
			pre_sum += arr[i]
			length += 1
		else:
			length = 0
			pre_sum = 0
		if pre_sum >= total and length < n:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
n = []
a = []
for _ in range(t):
	n.append(int(input()))
	a.append([int(i) for i in input().split()])
for i in range(t):
	first = a[i][1:]
	second = a[i][:len(a[i]) - 1]
	ans1 = -float('inf')
	ans2 = -float('inf')
	sum1 = 0
	for p in first:
		sum1 += p
		ans1 = max(ans1, sum1)
		sum1 = max(sum1, 0)
	sum2 = 0
	for p in second:
		sum2 += p
		ans2 = max(ans2, sum2)
		sum2 = max(sum2, 0)
	sum3 = sum(a[i])
	sum4 = max(ans1, ans2)
	if sum3 > sum4:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	yas = sum(a)
	adel = 0
	s = 0
	for i in range(1, n):
		s = max(s + a[i], 0)
		adel = max(adel, s)
	s = 0
	for i in range(n - 1):
		s = max(s + a[i], 0)
		adel = max(adel, s)
	if adel >= yas:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	yasser = sum(arr)
	i = 0
	flag = 0
	pre = 0
	while i < n - 1:
		pre += arr[i]
		x = yasser - pre
		if pre <= 0 or x <= 0:
			flag = 1
			break
		i += 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = sum(l)
	c = l[0]
	d = 0
	for i in range(n - 1):
		d += l[i]
		c = max(c, d)
		if d < 0:
			d = 0
	c = max(c, l[1])
	d = 0
	for i in range(1, n):
		d += l[i]
		c = max(c, d)
		if d < 0:
			d = 0
	if x > c:
		print('YES')
	else:
		print('NO')


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
tc = int(input())
for i in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	x1 = maxSubArraySum(a[1:], n - 1)
	x2 = maxSubArraySum(a[:n - 1], n - 1)
	x = max(x1, x2)
	if s > x:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ans = 'YES'
	st = 0
	for j in range(N - 1):
		st += A[j]
		if st <= 0:
			ans = 'NO'
	st = 0
	for j in range(N - 1):
		st += A[-j - 1]
		if st <= 0:
			ans = 'NO'
	print(ans)


def maxSubArraySum(a, size):
	max_so_far = -10000000001
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	yasser = sum(l)
	adnan = max(maxSubArraySum(l[1:], n - 1), maxSubArraySum(l[:n - 1], n - 1))
	if yasser > adnan:
		print('YES')
	else:
		print('NO')


def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far

def case():
	n = int(input())
	a = list(map(int, input().split()))
	ans1 = maxSubArraySum(a[1:], n - 1)
	ans2 = maxSubArraySum(a[:-1], n - 1)
	s = sum(a)
	if s > max(ans1, ans2):
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	case()


def solve():
	input()
	a = list(map(int, input().split()))
	s = 0
	for item in a:
		s += item
		if s <= 0:
			return 0
	s = 0
	for item in reversed(a):
		s += item
		if s <= 0:
			return 0
	return 1
for _ in range(int(input())):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a_list = list(map(int, input().split()))
	min_val = 0
	max_val = 0
	yasser = 0
	adel = a_list[0]
	last_pos = -1
	for j in range(n):
		yasser += a_list[j]
		if yasser > max_val and (not j - last_pos == n):
			adel = max(adel, yasser - min_val)
			max_val = yasser
			continue
		if yasser <= min_val:
			min_val = yasser
			max_val = yasser
			last_pos = j
	if yasser > adel:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	cakes = [int(x) for x in input().split(' ')]
	tot_sum = 0
	max_sub_sum = 0
	cur_sum = 0
	start = 0
	for i in range(len(cakes)):
		if cakes[i] >= cur_sum + cakes[i]:
			cur_sum = cakes[i]
			start = i
		else:
			cur_sum = cur_sum + cakes[i]
		if cur_sum > max_sub_sum:
			if not (start == 0 and i == n - 1):
				max_sub_sum = cur_sum
		tot_sum += cakes[i]
	if tot_sum > max_sub_sum:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = sum(a)
	y = -988998789897879
	z = 1
	i = 0
	cnt = 0
	while i < n:
		if z == n:
			cnt -= a[0]
		cnt += a[i]
		y = max(y, cnt)
		i += 1
		z += 1
		if cnt <= 0:
			z = i
			cnt = 0
	if x > y:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	s = 0
	ans = sum(a)
	cnt = 0
	cntb = 1
	for x in a:
		s += x
		ans = max(ans, s - c)
		if ans == s - c:
			cnt += cntb
		if c > s:
			cntb = 0
			c = s
		if c == s:
			cntb += 1
	if ans > sum(a) or cnt > 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def maxSubArraySum(arr, size):
	max_so_far = -10 ** 10 - 1
	max_so_far1 = -10 ** 10 - 1
	max_ending_here = 0
	s = sum(arr)
	for i in range(0, size - 1):
		max_ending_here = max_ending_here + arr[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	max_ending_here = 0
	for i in range(1, size):
		max_ending_here = max_ending_here + arr[i]
		if max_so_far1 < max_ending_here:
			max_so_far1 = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	if max_so_far >= s or max_so_far1 >= s:
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(maxSubArraySum(arr, n))


T = int(input())
for _ in range(T):
	n = int(input())
	a_i = [int(x) for x in input().split()]
	n_seq = False
	y_i = [0]
	for (idx, a) in enumerate(a_i):
		if idx != 0 and y_i[idx] + a <= a:
			n_seq = True
		y = max(y_i[idx] + a, a)
		y_i.append(y)
	if not n_seq:
		y_i = y_i[:-1]
	y_yas = sum(a_i)
	y_adl = max(y_i)
	if y_adl < y_yas:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	y = z = 0
	a = list(map(int, input().split()))
	ans = 'YES'
	x = sum(a)
	yy = max(a)
	for i in range(1, n):
		y += a[i]
		y = max(0, y)
		yy = max(yy, y)
	for i in range(0, n - 1):
		z += a[i]
		z = max(0, z)
		yy = max(yy, z)
	if x > yy:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = True
	acc = [0]
	for ai in a:
		acc.append(acc[-1] + ai)
	for i in range(1, n + 1):
		if acc[i] <= 0:
			flag = False
	acc = [0]
	a = a[::-1]
	for ai in a:
		acc.append(acc[-1] + ai)
	for i in range(1, n + 1):
		if acc[i] <= 0:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	line = [int(i) for i in input().split()]
	yasser = sum(line)
	mass = [[0, 0, 0], [0, 0, 0]]
	for i in range(n):
		mass[0][2] = max(mass[0])
		mass[1][2] = max(mass[1])
		if line[i] < 0:
			if i >= 1:
				mass[0] = [max(mass[0][0], mass[0][1]) + line[i], 0, mass[0][2]]
			if i < n - 1:
				mass[1] = [max(mass[1][0], mass[1][1]) + line[i], 0, mass[1][2]]
		else:
			if i >= 1:
				mass[0][0] += line[i]
				mass[0][1] += line[i]
			if i < n - 1:
				mass[1][0] += line[i]
				mass[1][1] += line[i]
	answer = max(max(mass[0]), max(mass[1]))
	print('YES' if yasser > answer else 'NO')


t = int(input())
for tt in range(0, t):
	n = int(input())
	x = input()
	a = x.split()
	s = 0
	c = 0
	p = 0
	for i in range(0, len(a)):
		s = s + int(a[i])
		c = c + int(a[len(a) - 1 - i])
		if s <= 0 or c <= 0:
			print('NO')
			p = 1
			break
	if p == 0:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	msf = 0
	meh = 0
	for j in range(1, n):
		if meh + a[j] < 0:
			meh = 0
		else:
			meh += a[j]
		if msf < meh:
			msf = meh
	meh = 0
	msf1 = 0
	for j in range(0, n - 1):
		if meh + a[j] < 0:
			meh = 0
		else:
			meh += a[j]
		if msf1 < meh:
			msf1 = meh
	c = max(msf, msf1)
	if c >= s:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	inf = 10 ** 15
	dp1 = [-inf] * (n - 1)
	dp1[0] = a[0]
	for i in range(1, n - 1):
		dp1[i] = max(dp1[i - 1] + a[i], a[i])
	dp2 = [-inf] * (n - 1)
	dp2[0] = a[1]
	for i in range(2, n):
		dp2[i - 1] = max(dp2[i - 2] + a[i], a[i])
	if max(dp1 + dp2) < sum(a):
		print('YES')
	else:
		print('NO')


I = input

def func(my_list):
	array = [0 for i in range(len(my_list))]
	for i in range(len(array)):
		array[i] = max(0, array[i - 1]) + my_list[i] if i != 0 else my_list[i]
	if max(array) == sum(my_list) and max(array) != sorted(array)[-2]:
		return max(array) - min(array)
	else:
		return max(array)
for _ in [0] * int(I()):
	I()
	ans = list(map(int, I().split()))
	Yasser = sum(ans)
	Adel = func(ans)
	if Yasser > Adel:
		print('YES')
	else:
		print('NO')


import collections

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	target = sum(l)
	total = l[0]
	ans = total
	hasBreak = False
	if ans >= target:
		print('NO')
		return
	for cur in l[1:-1]:
		if total > 0:
			total += cur
		else:
			hasBreak = True
			total = cur
		ans = max(ans, total)
		if ans >= target:
			print('NO')
			return
	cur = l[-1]
	if cur >= target or (hasBreak and total + cur >= target):
		print('NO')
		return
	print('YES')
	return
for _ in range(int(input())):
	solve()


import sys

def get(arr):
	total = sum(arr)
	(l, r, s) = (0, 0, 0)
	n = len(arr)
	while r < n:
		if s + arr[r] > 0:
			s += arr[r]
			if s >= total and (not (l == 0 and r == n - 1)):
				return False
			r += 1
		elif s + arr[r] <= 0:
			s += arr[r]
			while l <= r and s <= 0:
				s -= arr[l]
				l += 1
				if s >= total and (not (l == 0 and r == n - 1)):
					return False
			if l > r:
				(l, r) = (l, l)
	return True
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	if get(l):
		print('YES')
	else:
		print('NO')


def okay(al, n):
	acl = [0] * (n + 1)
	for i in range(n):
		acl[i + 1] = acl[i] + al[i]
	y = acl[-1]
	acl[0] = 1
	acl[-1] -= 1
	b = max(acl) - min(acl)
	return y > b + 1
t = int(input())
for _ in range(t):
	n = int(input())
	al = [int(s) for s in input().split()]
	print('YES' if okay(al, n) else 'NO')


def ans(arr, n):
	left = arr[0]
	if left <= 0:
		return False
	for i in range(1, n):
		left += arr[i]
		if left <= 0:
			return False
	right = arr[n - 1]
	if right <= 0:
		return False
	i = n - 2
	while i >= 0:
		right += arr[i]
		if right <= 0:
			return False
		i -= 1
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if ans(arr, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = [a[0]]
	for i in range(1, n):
		s.append(s[i - 1] + a[i])
	l = 0
	c = 0
	m = 0
	f = 0
	r = 0
	for i in range(n):
		if s[i] + c <= 0:
			l = i + 1
			c = -s[i]
		else:
			m = max(m, s[i] + c)
			if m >= s[-1]:
				r = i
				break
	if m >= s[-1] and r - l < n - 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = sum(a)
	q = 0
	l = 0
	for i in range(n - 1):
		l = max(a[i], a[i] + l)
		if l >= p:
			q = q + 1
			break
	l = 0
	for i in range(1, n):
		l = max(a[i], a[i] + l)
		if l >= p:
			q = q + 1
			break
	if q == 0:
		print('YES')
	else:
		print('NO')


o = int(input())
for _ in range(o):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	t = 0
	(res, su) = (0, 0)
	for i in l[1:]:
		if t == 0:
			if i > 0:
				t = 1
				su = i
				res = max(res, su)
		elif i > 0:
			su += i
			res = max(res, su)
		elif su + i > 0:
			res = max(res, su)
			su += i
		else:
			res = max(res, su)
			su = 0
			t = 0
	t = 0
	su = 0
	for i in l[:n - 1]:
		if t == 0:
			if i > 0:
				t = 1
				su = i
				res = max(res, su)
		elif i > 0:
			su += i
			res = max(res, su)
		elif su + i > 0:
			res = max(res, su)
			su += i
		else:
			res = max(res, su)
			su = 0
			t = 0
	if res < s:
		print('YES')
	else:
		print('NO')


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	dp = [0 for i in range(n)]
	dp[0] = li[0]
	for i in range(1, n):
		dp[i] = max(dp[i - 1] + li[i], li[i])
	z = sum(li)
	done = 0
	for i in range(n - 1):
		if dp[i] >= z:
			done = 1
	if dp[-1] > z:
		done = 1
	pref = 0
	for i in range(n - 1):
		pref += li[i]
		if pref == 0:
			done = 1
			break
	if done:
		print('NO')
	else:
		print('YES')


import math
num_tests = int(input())
out = []
for _ in range(num_tests):
	cup_cnt = int(input())
	cups = list(map(int, input().split(' ')))
	cups_sum = sum(cups)
	(min_sum, curr_sum) = (math.inf, 0)
	is_happy = 'YES'
	for idx in range(len(cups)):
		curr_sum += cups[idx]
		if idx < len(cups) - 1 and curr_sum >= cups_sum or min_sum <= curr_sum - cups_sum:
			is_happy = 'NO'
			break
		min_sum = min(min_sum, curr_sum)
	out.append(is_happy)
for val in out:
	print(val)


from itertools import accumulate
test_count = int(input())
for _ in range(test_count):
	_ = input()
	array = list(map(int, input().split()))
	s = sum(array)
	print('YES' if all((0 < i < s for i in list(accumulate(array))[:-1])) else 'NO')


def suma(a, size):
	maxi = -10 ** 9 - 1
	ending = 0
	for i in range(0, size):
		ending += a[i]
		if maxi < ending:
			maxi = ending
		if ending < 0:
			ending = 0
	return maxi
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sum(a)
	d = a[1:]
	c = suma(d, n - 1)
	r = a[:n - 1]
	e = suma(r, n - 1)
	if c < b and e < b:
		print('YES')
	else:
		print('NO')


tests = int(input())
n = []
numbers = []
for i in range(0, tests):
	n.append(int(input()))
	numbers.append(list(map(int, input().split())))
for tastes in numbers:
	flag = 0
	sum = 0
	for i in tastes:
		sum += i
	partial_sum = 0
	for i in tastes:
		if i <= 0:
			if partial_sum >= sum or -i >= partial_sum:
				print('NO')
				flag = 1
				break
		partial_sum += i
	if flag == 0:
		print('YES')


from itertools import accumulate
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	sl = list(accumulate(a))
	sr = list(accumulate(a[::-1]))
	tl = max(sl) - min(sl)
	tr = max(sr) - min(sr)
	if max(tl, tr) < sl[-1]:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for need in range(testcases):
	n = int(input())
	l = list(map(int, input().strip().split(' ')))
	result = [l[0]]
	yaseer = sum(l)
	for i in range(1, len(l) - 1):
		result.append(max(l[i], l[i] + result[i - 1]))
	adele1 = max(result)
	result = [-5435345345734578437589, l[1]]
	for i in range(2, len(l)):
		result.append(max(l[i], l[i] + result[i - 1]))
	adele2 = max(result)
	adele = max(adele1, adele2)
	if adele >= yaseer:
		print('NO')
	else:
		print('YES')


from sys import maxsize

def kadane(a):
	n = len(a)
	l = 0
	maxi = -maxsize - 1
	for i in range(n):
		l = l + a[i]
		if maxi < l:
			maxi = l
		if l < 0:
			l = 0
	return maxi
q = int(input())
while q > 0:
	n = int(input())
	a = [int(ele) for ele in input().split()]
	Y = 0
	for ele in a:
		Y += ele
	A1 = kadane(a[1:])
	A2 = kadane(a[0:n - 1])
	A = max(A1, A2)
	if Y > A:
		print('YES')
	else:
		print('NO')
	q -= 1


def find_ans(n, s):
	yasser = sum(s)
	adel = 0
	ll = s[0]
	k = j = 0
	for i in range(1, n):
		if ll <= 0:
			ll = 0
			k = i + 1
		if s[i] < 0:
			if adel <= ll:
				adel = ll
				j = k
		ll += s[i]
	if ll > adel and k == 0:
		return 'YES'
	else:
		adel = ll
	if adel >= yasser:
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	print(find_ans(n, s))


for j in range(int(input())):
	n = int(input())
	arr = [int(k) for k in input().split()]
	c = 0
	for i in range(n - 1):
		arr[i + 1] = arr[i] + arr[i + 1]
		if arr[i + 1] <= 0:
			c = c + 1
	if arr[0] <= 0:
		c = c + 1
	max = arr[0]
	for i in range(n - 1):
		if arr[i] > max:
			max = arr[i]
	if max >= arr[n - 1] or c > 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	max_s = -999999
	for aa in a[:-1]:
		s = max(s, 0) + aa
		max_s = max(max_s, s)
	s2 = 0
	max_s2 = -999999
	for aa in a[1:]:
		s2 = max(s2, 0) + aa
		max_s2 = max(max_s2, s2)
	if max(max_s, max_s2) < sum(a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	flag = True
	this = 0
	for i in array:
		this += i
		if this <= 0:
			flag = False
			break
	if flag == False:
		print('NO')
		continue
	this = 0
	flag = True
	for i in array[::-1]:
		this += i
		if this <= 0:
			flag = False
			break
	if flag == False:
		print('NO')
		continue
	print('YES')


t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	sm = sum(l)
	sm2 = 0
	ch = 1
	ind1 = 0
	for i in range(n):
		if sm2 <= 0:
			sm2 = 0
			ind1 = i
		sm2 += l[i]
		if sm2 >= sm:
			if i != n - 1 or ind1 != 0:
				ch = 0
				break
	if ch == 1:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	add = 0
	for i in range(len(a)):
		add += a[i]
		if add <= 0:
			return 0
	add = 0
	for i in range(len(a) - 1, -1, -1):
		add += a[i]
		if add <= 0:
			return 0
	return 1
t = int(input())
while t:
	if main():
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	A = tuple(map(int, input().split()))
	y = sum(A)
	t = a = 0
	for i in range(n - 1):
		t += A[i]
		if t > a:
			a = t
		elif t < 0:
			t = 0
	t = 0
	for i in range(1, n):
		t += A[i]
		if t > a:
			a = t
		elif t < 0:
			t = 0
	if y > a:
		print('YES')
	else:
		print('NO')


tests = input()
tests = int(tests)
for p in range(tests):
	n = input()
	n = int(n)
	arr = []
	yasser = 0
	adel = -100
	k = input()
	k = k.split(' ')
	for i in range(n):
		k[i] = int(k[i])
		yasser += k[i]
		arr.append(k[i])
	s = 0
	e = len(arr) - 1
	tempS = yasser - arr[s]
	tempE = yasser - arr[e]
	adel = max(tempS, tempE)
	for i in range(len(arr) - 1):
		if tempS > adel:
			adel = tempS
		if tempE > adel:
			adel = tempE
		s += 1
		e -= 1
		tempS -= arr[s]
		tempE -= arr[e]
	if yasser > adel:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	yasser = 0
	adel = -10 ** 9
	val = 0
	val2 = 0
	x = list(map(int, input().strip().split()))
	for j in range(n):
		yasser = yasser + x[j]
		if j == 0:
			if val + x[j] > 0:
				val = val + x[j]
				adel = max(adel, val)
			else:
				adel = max(adel, x[j])
				val = 0
		elif j == n - 1:
			if val2 + x[j] > 0:
				val2 = val2 + x[j]
				adel = max(adel, val2)
			else:
				adel = max(adel, x[j])
				val2 = 0
		else:
			if val + x[j] > 0:
				val = val + x[j]
				adel = max(adel, val)
			else:
				adel = max(adel, x[j])
				val = 0
			if val2 + x[j] > 0:
				val2 = val2 + x[j]
				adel = max(adel, val2)
			else:
				adel = max(adel, x[j])
				val2 = 0
	if yasser > adel:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	lst = list(map(int, stdin.readline().split()))
	sum1 = 0
	sum2 = 0
	for i in range(0, n - 1):
		sum1 += lst[i]
		sum2 += lst[n - i - 1]
		if sum1 <= 0 or sum2 <= 0:
			stdout.write('NO\n')
			break
	else:
		stdout.write('YES\n')


def maxSubArraySum(a, size):
	max_so_far = -99999999999999999999 - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
n = int(input())
for ifnjfnjf in range(n):
	kkgg = input()
	arr1 = str(input())
	arr2 = arr1.split()
	arr = []
	for i in arr2:
		arr.append(int(i))
	yar = sum(arr)
	if len(arr) == 1:
		print('NO')
		continue
	left = arr[:-1]
	right = arr[1:]
	nn = len(left)
	left2 = maxSubArraySum(left, nn)
	right2 = maxSubArraySum(right, nn)
	if left2 >= yar or right2 >= yar:
		print('NO')
	else:
		print('YES')


def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		score1 = sum(arr)
		score2 = float('-inf')
		counter = 0
		for i in range(n - 1):
			counter += arr[i]
			score2 = max(score2, counter)
			counter = max(counter, 0)
		counter = 0
		for i in range(1, n):
			counter += arr[i]
			score2 = max(score2, counter)
			counter = max(counter, 0)
		print('YES' if score1 > score2 else 'NO')
main()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().strip().split()))
	S = sum(arr)
	if S < 0:
		print('NO')
		continue
	m = 0
	for i in range(n - 1):
		m += arr[i]
		if m <= 0 or m >= S:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	pos = 0
	neg = 0
	z = 0
	for i in l:
		if i < 0:
			neg = neg + 1
		elif i > 0:
			pos = pos + 1
		elif i == 0:
			z = z + 1
	if neg == n:
		print('NO')
	elif pos == n:
		print('YES')
	elif neg + z == n:
		print('NO')
	elif z + pos == n:
		if l[0] == 0 or l[n - 1] == 0:
			print('NO')
		else:
			print('YES')
	else:
		total = sum(l)
		flag = 0
		j = 0
		for i in range(n):
			if i != n - 1:
				s = s + l[i]
			elif j != 0:
				s = s + l[i]
			if s >= total:
				print('NO')
				flag = 1
				break
			elif s <= 0:
				s = 0
				j = i + 1
		if flag == 0:
			print('YES')


q = int(input())
for qq in range(q):
	n = int(input())
	arr = [int(i) for i in filter(None, input().split(' '))]
	s = 0
	ans = 'YES'
	for i in range(len(arr)):
		s += arr[i]
		if s <= 0:
			ans = 'NO'
	s = 0
	for i in range(len(arr)):
		s += arr[n - i - 1]
		if s <= 0:
			ans = 'NO'
	print(ans)


def max_arr_sum(arr):
	l = len(arr)
	ans = temp = 0
	for i in range(l):
		temp = max(temp + arr[i], arr[i])
		ans = max(ans, temp)
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = sum(a)
	ans = max(max_arr_sum(a[1:]), max_arr_sum(a[:-1]))
	if k > ans:
		print('YES')
	else:
		print('NO')


from sys import stdin

def solve(a):
	pre = 0
	for i in a:
		pre += i
		if pre <= 0:
			return 'NO'
	suf = 0
	for i in a[::-1]:
		suf += i
		if suf <= 0:
			return 'NO'
	return 'YES'
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	print(solve(a))
	t -= 1


for case in range(int(input())):
	size = int(input())
	arr = tuple(map(int, input().split()))
	Sum = sum(arr)
	s = Max = start = 0
	ans = True
	for i in range(size):
		s += arr[i]
		Max = max(Max, s)
		if Max > Sum or (Max == Sum and (start != 0 or i != size - 1)):
			ans = False
			break
		if s <= 0:
			s = 0
			start = i + 1
	print('YES' if ans else 'NO')


def is_yasser_happy(length, tastiness):
	total = sum(tastiness)
	count = 0
	for i in range(length - 1):
		count += tastiness[i]
		if count <= 0 or count >= total:
			return 'NO'
	return 'YES'

def solution(inp1, inp2):
	return is_yasser_happy(inp1, inp2)

def main():
	inp1 = input()
	length = int(inp1)
	for i in range(length):
		inp2 = int(input())
		inp3 = list(map(int, input().split()))
		result = solution(inp2, inp3)
		print(result)
main()


import copy

def smth(to_start, lst, n, sm1):
	lst = copy.deepcopy(lst[to_start:len(lst) - (1 - to_start)])
	sm = 0
	fst_to_take = 0
	for i in range(len(lst)):
		sm += lst[i]
		if sm < 0:
			sm = 0
			fst_to_take = i + 1
	if fst_to_take == len(lst):
		if sm1 > sm:
			return True
		else:
			print('NO')
			return False
	lst = list(reversed(lst[fst_to_take:]))
	sm = 0
	for i in range(len(lst)):
		sm += lst[i]
		if sm < 0:
			sm = 0
			fst_to_take = i + 1
	if sm1 > sm:
		return True
	if len(lst) - fst_to_take == n:
		return True
	else:
		print('NO')
		return False

def main():
	n = int(input())
	lst = list(map(int, input().split()))
	sm = 0
	for i in range(len(lst)):
		sm += lst[i]
	if smth(0, lst, n, sm):
		if smth(1, lst, n, sm):
			print('YES')
t = int(input())
for i in range(t):
	main()


from collections import deque
import itertools
import operator
import queue
import time
import math
import sys
import os

def max_sub(a, n):
	ans = a[0]
	ans_l = 0
	ans_r = 0
	summ = 0
	min_sum = 0
	min_pos = -1
	for i in range(n):
		summ += a[i]
		cur = summ - min_sum
		if cur > ans:
			ans = cur
			ans_l = min_pos + 1
			ans_r = i
		if summ < min_sum:
			min_sum = summ
			min_pos = i
	return ans
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if max_sub(a[0:n - 1], n - 1) >= s or max_sub(a[1:n], n - 1) >= s:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	hihi = [0]
	for i in range(1, n + 1):
		hihi.append(hihi[-1] + arr[i - 1])
	if max(hihi[1:]) - min(hihi[1:]) >= hihi[-1] or max(hihi[:-1]) - min(hihi[:-1]) >= hihi[-1]:
		print('NO')
	else:
		print('YES')


t = int(input())
for j in range(t):
	n = int(input())
	tasty = input().split()
	for x in range(n):
		tasty[x] = int(tasty[x])
	pre1 = 0
	for x in tasty:
		pre1 = pre1 + x
		if pre1 <= 0:
			break
	pre2 = 0
	for x in range(n - 1, -1, -1):
		pre2 = pre2 + tasty[x]
		if pre2 <= 0:
			break
	if pre1 <= 0 or pre2 <= 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	prefix = [0] * n
	suffix = [0] * n
	prefix[0] = nums[0]
	suffix[0] = nums[-1]
	for i in range(1, n):
		prefix[i] = prefix[i - 1]
		prefix[i] += nums[i]
	nums = nums[::-1]
	for i in range(1, n):
		suffix[i] = suffix[i - 1]
		suffix[i] += nums[i]
	if any((i <= 0 for i in prefix)) or any((i <= 0 for i in suffix)):
		print('NO')
	else:
		print('YES')


def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
n = int(input())
while n:
	n -= 1
	m = int(input())
	l = list(map(int, input().split()))
	k1 = maxSubArraySum(l[1:], m - 1)
	k2 = maxSubArraySum(l[:-1], m - 1)
	p = max(k1, k2)
	if sum(l) > p:
		print('YES')
	else:
		print('NO')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def isYasserHappy(n, a):
	leftSum = 0
	for el in a:
		leftSum += el
		if leftSum <= 0:
			return False
	rightSum = 0
	for el in reversed(a):
		rightSum += el
		if rightSum <= 0:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print('YES' if isYasserHappy(n, a) else 'NO')


for i in range(int(input())):
	n = int(input())
	values = list(map(int, input().split()))
	total = sum(values)
	su = 0
	hey = 0
	for val in values[:n - 1]:
		su += val
		if su <= 0:
			print('NO')
			hey = 1
			break
		elif su >= total:
			print('NO')
			hey = 1
			break
	if hey == 0 and values[n - 1] > 0:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	yasar = sum(l)
	if n == 1:
		print('NO')
	else:
		m1 = 0
		csum = 0
		for i in range(1, n):
			csum += l[i]
			if csum > m1:
				m1 = csum
			if csum < 0:
				csum = 0
		m2 = 0
		csum = 0
		for i in range(n - 1):
			csum += l[i]
			if csum > m2:
				m2 = csum
			if csum < 0:
				csum = 0
		if yasar > max(m1, m2):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = 0
	l = 0
	p = 0
	for j in range(n):
		s += b[j]
		l += b[n - j - 1]
		if s <= 0:
			p = 1
			break
		if l <= 0:
			p = 1
			break
	if p == 1:
		print('NO')
	else:
		print('YES')


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for y in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	me = 0
	ms = 0
	for i in range(1, n):
		me = max(me + a[i], 0)
		ms = max(ms, me)
	me = 0
	for i in range(n - 1):
		me = max(me + a[i], 0)
		ms = max(ms, me)
	if ms >= sum(a):
		print('NO')
	else:
		print('YES')


def solve(a):
	n = len(a)
	s = sum(a)
	s1 = 0
	for i in range(n):
		s1 += a[i]
		if s1 <= 0:
			return 0
	s1 = 0
	for i in range(n):
		s1 += a[n - i - 1]
		if s1 <= 0:
			return 0
	return 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = solve(a)
	if ans == 0:
		print('NO')
	else:
		print('YES')


a = int(input())
for i in range(a):
	b = int(input())
	arr = list(map(int, input().split()))
	tas = sum(arr)
	ade = 0
	count = 0
	k = 0
	for i in range(0, len(arr)):
		if arr[i] + ade >= tas:
			k = 1
			count = count + 1
			break
		if arr[i] + ade > 0:
			ade = ade + arr[i]
			count = count + 1
		else:
			ade = 0
			count = 0
	if count == len(arr):
		print('YES')
	else:
		print('NO')


mod = 10 ** 9 + 7
import math
from itertools import combinations

def ain():
	return map(int, input().split())

def fain():
	return map(float, input().split())

def maxCrossingSum(arr, l, m, h):
	sm = 0
	left_sum = -10000
	for i in range(m, l - 1, -1):
		sm = sm + arr[i]
		if sm > left_sum:
			left_sum = sm
	sm = 0
	right_sum = -1000
	for i in range(m + 1, h + 1):
		sm = sm + arr[i]
		if sm > right_sum:
			right_sum = sm
	return left_sum + right_sum

def maxSubArraySum(arr, l, h):
	if l == h:
		return arr[l]
	m = (l + h) // 2
	return max(maxSubArraySum(arr, l, m), maxSubArraySum(arr, m + 1, h), maxCrossingSum(arr, l, m, h))
for _ in range(int(input())):
	n = int(input())
	l = list(ain())
	s1 = maxSubArraySum(l, 0, n - 2)
	s2 = maxSubArraySum(l, 1, n - 1)
	s = max(s1, s2)
	if s >= sum(l):
		print('NO')
	else:
		print('YES')


def Fun(lst, n):
	max_so_far = lst[1]
	max_end_here = lst[1]
	for i in range(2, n):
		max_end_here = max(max_end_here + lst[i], lst[i])
		if max_so_far < max_end_here:
			max_so_far = max_end_here
	first = max_so_far
	max_so_far = lst[0]
	max_end_here = lst[0]
	for i in range(1, n - 1):
		max_end_here = max(max_end_here + lst[i], lst[i])
		if max_so_far < max_end_here:
			max_so_far = max_end_here
	return max(first, max_so_far)
t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	first = sum(lst)
	second = Fun(lst, n)
	if first > second:
		print('YES')
	else:
		print('NO')


import sys, math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	n = inp()
	a = inlt()
	q = a[0]
	w = a[0]
	for i in range(1, len(a) - 1):
		q = max(a[i], q + a[i])
		w = max(q, w)
	qw = w
	q = a[1]
	w = a[1]
	for i in range(2, len(a)):
		q = max(a[i], q + a[i])
		w = max(q, w)
	if sum(a) > max(w, qw):
		print('YES')
	else:
		print('NO')


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().split(' ')))
	f = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s <= 0:
			f = 1
	c = 0
	s = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s <= 0:
			c = 1
	if f == 1 or c == 1:
		print('NO')
	else:
		print('YES')
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


def f(l):
	if len(l) == 1:
		return (l[0], l[0], -1000000000000000)
	left = l[:len(l) // 2]
	right = l[len(l) // 2:]
	(min1, max1, sub1) = f(left)
	(min2, max2, sub2) = f(right)
	return (min(min1, min2), max(max1, max2), max(max2 - min1, sub1, sub2, max2))

def h(ll):
	max0 = -1000000000000
	for i in range(len(ll) - 1):
		if max0 < ll[i]:
			max0 = ll[i]
	l = ll
	l.reverse()
	r = []
	r.append(-1000000000000000000)
	for i in range(1, len(l)):
		if i == 1:
			r.append(l[0])
		else:
			r.append(max(r[i - 1], l[i - 1]))
	maxr = -1000000000000000
	for i in range(len(r)):
		if maxr < r[i] - l[i]:
			maxr = r[i] - l[i]
	return max(maxr, max0)

def g(l):
	r = []
	r.append(l[0])
	for i in range(1, len(l)):
		r.append(l[i] + r[i - 1])
	return r
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = h(g(l))
	y = 0
	for i in l:
		y += i
	if x < y:
		print('YES')
	else:
		print('NO')


def modified_kadane(arr):
	max_so_far = arr[0]
	max_end_here = 0
	start = end = 0
	for i in range(0, len(arr)):
		if max_end_here <= 0:
			max_end_here = 0
			start = i
			end = i
		max_end_here += arr[i]
		if max_so_far < max_end_here:
			max_so_far = max_end_here
			end = i
	if end - start + 1 == len(arr):
		return max(max_so_far - arr[0], max_so_far - arr[len(arr) - 1])
	return max_so_far
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	yasser = 0
	for x in arr:
		yasser += x
	adele = modified_kadane(arr)
	if yasser > adele:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	total = sum(a)
	maxSubarraySum = -float('inf')
	curMaxSubarraysum = -float('inf')
	for x in a[1:]:
		curMaxSubarraysum = max(curMaxSubarraysum + x, x)
		maxSubarraySum = max(maxSubarraySum, curMaxSubarraysum)
	curMaxSubarraysum = -float('inf')
	for x in a[:-1]:
		curMaxSubarraysum = max(curMaxSubarraysum + x, x)
		maxSubarraySum = max(maxSubarraySum, curMaxSubarraysum)
	if total > maxSubarraySum:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	b = a[:len(a) - 1]
	max_so_far = -10 ** 30
	max_ending_here = 0
	for i in range(0, len(b)):
		max_ending_here = max_ending_here + b[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	a1 = max_so_far
	b = a[1:]
	max_so_far = -10 ** 30
	max_ending_here = 0
	for i in range(0, len(b)):
		max_ending_here = max_ending_here + b[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	if max(max_so_far, a1) >= sm:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [0] * (n + 1)
	dp[1] = a[0]
	m1 = 0
	im1 = 0
	m2 = 1000000000.0
	im2 = 0
	ma1 = 0
	ima1 = 0
	ma2 = 0
	ima2 = 0
	s = 0
	for i in range(1, n + 1):
		dp[i] = dp[i - 1] + a[i - 1]
		if dp[i] < m1:
			m2 = m1
			m1 = dp[i]
			im2 = im1
			im1 = i
		elif dp[i] < m2:
			m2 = dp[i]
			im2 = i
		if dp[i] > ma1:
			ma2 = ma1
			ma1 = dp[i]
			ima2 = ima1
			ima1 = i
		elif dp[i] > ma2:
			ma2 = dp[i]
			ima2 = i
		s += a[i - 1]
	if im1 != 0 or ima1 != n:
		answer = ma1 - m1
	else:
		answer = max(ma1 - m2, ma2 - m1)
	if answer < s:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	f = 0
	cur = 0
	m = 0
	times = 0
	pre = [l[0]]
	for i in range(n):
		if i != 0:
			pre.append(pre[-1] + l[i])
		cur += l[i]
		m = max(m, cur)
		if cur <= 0:
			times += 1
			cur = 0
	if sum(l) == m:
		if 0 not in pre and sum(l) not in pre[:-1]:
			print('YES')
		else:
			print('NO')
		continue
	if m >= sum(l):
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	a = int(input())
	lis = list(map(int, input().split()))
	t = sum(lis)
	aa = lis[:a - 1]
	bb = lis[1:]
	l = r = s = 0
	ans = [0]
	while r < a - 1:
		s += aa[r]
		if s <= 0:
			s = 0
			l = r
			r += 1
		else:
			r += 1
			ans.append(s)
	r = s = 0
	while r < a - 1:
		s += bb[r]
		if s <= 0:
			s = 0
			l = r
			r += 1
		else:
			r += 1
			ans.append(s)
	if max(ans) < t:
		print('YES')
	else:
		print('NO')


from sys import *

def smsum(arr, n, x):
	curr_sum = 0
	min_len = n + 1
	start = 0
	flag = 0
	end = 0
	while end < n:
		while curr_sum <= x and end < n:
			if curr_sum <= 0 and x > 0:
				start = end
				curr_sum = 0
			curr_sum += arr[end]
			end += 1
		while curr_sum > x and start < n:
			if end - start < min_len:
				min_len = end - start
				if min_len < n:
					flag = 1
					break
			curr_sum -= arr[start]
			start += 1
		if flag == 1:
			break
	return min_len
t = int(input())
while t:
	t -= 1
	n = int(input())
	f1 = stdin.readline()
	a = list(map(int, f1.split()))
	f = smsum(a, n, sum(a) - 1)
	if f == n or f == n + 1:
		print('YES')
		continue
	print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	su = 0
	bad = False
	for item in a:
		if -item >= su:
			bad = True
		su += item
	su = 0
	for item in a[::-1]:
		if -item >= su:
			bad = True
		su += item
	if bad:
		print('NO')
	else:
		print('YES')


def maxi(a, b):
	max_so_far = 0
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(a, b):
		max_ending_here += l[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return max_so_far
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	yaseer = sum(l)
	adel = max(maxi(1, n), maxi(0, n - 1))
	if yaseer > adel:
		print('YES')
	else:
		print('NO')


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		s = 0
		flag = 0
		for i in range(n):
			s += l[i]
		if s <= 0:
			print('NO')
		else:
			suma = 0
			maxi = MIN
			x = 0
			r = 0
			for i in range(n):
				suma += l[i]
				if suma <= 0:
					suma = 0
					x = i + 1
				if maxi < suma:
					maxi = suma
					r = i
			if maxi > s:
				print('NO')
			elif maxi == s:
				if x == 0 and r == n - 1:
					print('YES')
				else:
					print('NO')
			else:
				print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, itertools
T = int(sys.stdin.readline())

def kadane(A):
	max_so_far = 0
	max_ending_here = 0
	(start, end) = (0, 0)
	for (i, a) in enumerate(A):
		max_ending_here = max_ending_here + a
		if max_ending_here < 0:
			max_ending_here = 0
			start = i + 1
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			end = i
		max_so_far = max(max_so_far, max_ending_here)
	return max_so_far
for _ in range(T):
	sys.stdin.readline()
	A = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	Y = sum(A)
	A1 = kadane(A[1:])
	A2 = kadane(A[:-1])
	if Y > A1 and Y > A2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	max = a[0]
	p = 0
	sum = a[0]
	l = 0
	s = a[0]
	for i in range(1, n):
		sum += a[i]
		if a[i] < s + a[i]:
			s = s + a[i]
			if s > max and (p == 1 or i != n - 1):
				max = s
		else:
			p = 1
			s = a[i]
			if s > max:
				max = s
	if p == 0:
		if sum - a[0] > max:
			max = sum - a[0]
	if max >= sum:
		print('NO')
	else:
		print('YES')


T = int(input())
for cs in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	tot = sum(a)
	mx = 0
	cur = 0
	for i in range(n - 1):
		cur += a[i]
		if cur < 0:
			cur = 0
		mx = max(mx, cur)
	cur = 0
	for i in range(1, n):
		cur += a[i]
		if cur < 0:
			cur = 0
		mx = max(mx, cur)
	if tot > mx:
		print('YES')
	else:
		print('NO')


def sumsub(l):
	(best, tot) = (0, 0)
	for x in l:
		tot += x
		best = max(best, tot)
		if tot < 0:
			tot = 0
	return best
for _ in range(int(input())):
	(_, vals) = (input(), list(map(int, input().split())))
	yasser = sum(vals)
	adel = max(sumsub(vals[1:]), sumsub(vals[:-1]))
	print('YES' if yasser > adel else 'NO')


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	ans = 'YES'
	cur = cur2 = 0
	for i in range(n):
		cur += l[i]
		cur2 += l[-i - 1]
		if cur <= 0:
			ans = 'NO'
		if cur2 <= 0:
			ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	f = 0
	x = 0
	for j in range(len(a) - 1):
		x = x + a[j]
		y = s - x
		if x <= 0 or y <= 0:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


def ssum(arr, st, end):
	maxi = -1000000001
	curr = 0
	for i in range(st, end + 1):
		curr += arr[i]
		if curr > maxi:
			maxi = curr
		if curr < 0:
			curr = 0
	return maxi
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = ssum(arr, 0, n - 2)
	ans = max(ans, ssum(arr, 1, n - 1))
	if ans >= sum(arr):
		print('NO')
	else:
		print('YES')


from itertools import accumulate
t = int(input())
for w in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	s = sum(arr)
	if all((0 < i < s for i in list(accumulate(arr))[:-1])):
		print('YES')
	else:
		print('NO')


def happy(n, a):
	p = []
	m = []
	m2 = []
	m.append(0)
	m2.append(10 ** 9)
	p.append(int(0))
	ans = 1
	for i in range(1, len(a) + 1):
		p.append(p[i - 1] + a[i - 1])
	for i in range(1, n + 1):
		m.append(min(m[i - 1], p[i]))
	for i in range(1, n + 1):
		m2.append(min(m2[i - 1], p[i]))
	ans = 1
	for i in range(1, n):
		if p[i] - m[i - 1] >= p[n]:
			ans = 0
	i = n
	if p[i] - m2[i - 1] >= p[n]:
		ans = 0
	if ans == 1:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(happy(n, a))


from collections import deque, Counter
from math import *
import sys
import random
from bisect import *
from functools import reduce
from sys import stdin
from heapq import *
import copy
input = lambda : sys.stdin.readline().rstrip()

def fin(arr):
	s = 0
	i = 0
	while i < n:
		s += arr[i]
		if s <= 0:
			return False
		i += 1
	i = len(arr) - 1
	s = 0
	while i >= 0:
		s += arr[i]
		if s <= 0:
			return False
		i -= 1
	return True
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print('YES' if fin(arr) == True else 'NO')


def mi():
	return list(map(int, input().split()))

def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	ade = max(maxSubArraySum(a, n - 1), maxSubArraySum(a[1:], n - 1))
	if sum(a) > ade:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	flag = 1
	sum = 0
	len = int(input())
	answ = 'YES'
	data = [int(i) for i in filter(None, input().split(' '))]
	for j in range(0, len):
		sum += data[j]
		if sum <= 0:
			answ = 'NO'
			flag = 0
	sum = 0
	for j in range(len - 1, 0, -1):
		sum += data[j]
		if sum <= 0:
			answ = 'NO'
	print(answ)


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max(max_so_far, max(a))
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cy = sum(a)
	a1 = maxSubArraySum(a[1:], n - 1)
	a2 = maxSubArraySum(a[:n - 1], n - 1)
	ca = max(a1, a2)
	if cy > ca:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(1000)
t = int(input())
a = []
n = 0
INF = 999999999999999999

def lolMax(l, r, mid):
	global a
	ls = 0
	lss = -INF
	rs = 0
	rss = -INF
	for i in range(mid, l - 1, -1):
		ls += a[i]
		if ls > lss:
			lss = ls
	for i in range(mid + 1, r + 1):
		rs += a[i]
		if rs > rss:
			rss = rs
	return rss + lss

def maxSum(l, r):
	global a
	if l == r:
		return a[l]
	mid = (l + r) // 2
	return max([maxSum(l, mid), maxSum(mid + 1, r), lolMax(l, r, mid)])
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ss = sum(a)
	mmx1 = maxSum(0, n - 2)
	mmx2 = maxSum(1, n - 1)
	if mmx2 < ss and mmx1 < ss:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	m = 0
	s = 0
	lst = list(map(int, input().split()))
	for c in range(n - 1):
		s += lst[c]
		if m < s:
			m = s
		if s < 0:
			s = 0
	m1 = 0
	s = 0
	for c in range(1, n):
		s += lst[c]
		if m < s:
			m = s
		if s < 0:
			s = 0
	if sum(lst) > max(m1, m):
		print('YES')
	else:
		print('NO')


from sys import stdin

def kadane(a):
	max_current = max_global = a[0]
	for i in range(1, len(a)):
		max_current = max(a[i], max_current + a[i])
		if max_current > max_global:
			max_global = max_current
	return max_global

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		N = int(input())
		A = list(map(int, input().split()))
		Yasser = sum(A)
		Adel = max(kadane(A[1:]), kadane(A[:-1]))
		if Yasser > Adel:
			print('YES')
		else:
			print('NO')
main()


def binarySearch(arr, x):
	l = 0
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	s = sum(ar)
	count = 0
	ans = 'YES'
	for i in range(n - 1):
		count += ar[i]
		if count >= s:
			ans = 'NO'
			break
		elif count < 0:
			count = 0
	if count > s:
		ans = 'NO'
	count = 0
	for i in range(1, n):
		count += ar[i]
		if count >= s:
			ans = 'NO'
			break
		elif count < 0:
			count = 0
	if count > s:
		ans = 'NO'
	print(ans)


def kandane(z):
	cur = z[0]
	maxa = z[0]
	start = 1
	end = 1
	for i in range(1, len(z)):
		cur = max(cur + z[i], z[i])
		maxa = max(maxa, cur)
	return maxa
a = int(input())
for i in range(a):
	x = input()
	z = list(map(int, input().split()))
	t = z.copy()
	r = z.copy()
	w = z.copy()
	t[0] = 0
	r[-1] = 0
	w[0] = 0
	w[-1] = 0
	m2 = kandane(t)
	m3 = kandane(r)
	m4 = kandane(w)
	if len(z) == 2:
		if max(m2, m3) >= sum(z):
			print('NO')
		else:
			print('YES')
	elif max(m2, m3, m4) >= sum(z):
		print('NO')
	else:
		print('YES')


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	r = a[0]
	c = 0
	s = 0
	for i in range(n - 1):
		r = max(r, a[i])
		s += a[i]
		c += 1
		if s < 0:
			s = 0
			c = 0
		if c > 0:
			r = max(r, s)
	s = 0
	c = 0
	for i in range(1, n):
		r = max(r, a[i])
		s += a[i]
		c += 1
		if s < 0:
			s = 0
			c = 0
		if c > 0:
			r = max(r, s)
	print(['NO', 'YES'][sum(a) > r])
for i in range(mint()):
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	it = list(map(int, input().split()))
	su = 0
	ma = -float('inf')
	for i in range(n - 1):
		su += it[i]
		ma = max(ma, su)
		su = max(su, 0)
	su = 0
	for i in range(1, n):
		su += it[i]
		ma = max(ma, su)
		su = max(su, 0)
	if sum(it) > ma:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	tastes = list(map(int, input().split()))
	tSum = sum(tastes)
	preS = list()
	preS.append(0)
	s = 0
	for x in tastes:
		s += x
		preS.append(s)
	minI = 0
	pStr = 'YES'
	for i in range(1, len(preS) - 1):
		if preS[i] - preS[minI] >= tSum:
			pStr = 'NO'
			break
		if preS[i] < preS[minI]:
			minI = i
	end = len(preS) - 1
	minI = 1
	for i in range(2, len(preS) - 1):
		if preS[i] < preS[minI]:
			minI = i
	if preS[end] - preS[minI] >= tSum:
		pStr = 'NO'
	print(pStr)


def maxSubArraySum(a, size):
	max_so_far = -10 ** 10
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = sum(a)
	m = maxSubArraySum(a[:n - 1], len(a) - 1)
	m = max(m, maxSubArraySum(a[1:], len(a) - 1))
	if x > m:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	c = int(sys.stdin.readline().rstrip())
	cupcakes = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	c_sum = [0]
	s = sum(cupcakes)
	maximum = 0
	result = 0
	b = True
	for i in cupcakes:
		result += i
		c_sum.append(result)
	maximum = 0
	maximum_index = -1
	minimum = 100000000
	minimum_index = -1
	for i in range(c + 1):
		if c_sum[i] > maximum:
			maximum = c_sum[i]
			maximum_index = i
		if c_sum[i] <= minimum:
			minimum = c_sum[i]
			minimum_index = i
	if maximum_index == c and minimum_index == 0:
		print('YES')
	elif s > maximum - minimum:
		print('YES')
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	dp = [0] * len(arr)
	dp[0] = arr[0]
	start = 0
	for i in range(1, len(arr)):
		if arr[i] + dp[i - 1] > arr[i]:
			dp[i] = arr[i] + dp[i - 1]
		else:
			dp[i] = arr[i]
			start = i
	if start == 0:
		adel = max(max(dp[1:]) - dp[start], max(dp[:-1]))
	else:
		adel = max(dp)
	if s > adel:
		print('YES')
	else:
		print('NO')


maxint = 100000000 + 4

def maxSubArraySum(a, size):
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	s1 = sum(l)
	l1 = [l[i] for i in range(0, len(l) - 1)]
	l2 = [l[i] for i in range(1, len(l))]
	s2 = max(maxSubArraySum(l1, len(l1)), maxSubArraySum(l2, len(l2)))
	if s1 > s2:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	maxi1 = -9999999
	tempmax = maxi1
	flag = 0
	sumA = sum(A)
	for i in range(1, N):
		tempmax = max(tempmax + A[i], A[i])
		maxi1 = max(maxi1, tempmax)
	maxi2 = -9999999
	tempmax = maxi2
	for i in range(N - 1):
		tempmax = max(tempmax + A[i], A[i])
		maxi2 = max(maxi2, tempmax)
	if max(maxi1, maxi2) < sumA:
		print('YES')
	else:
		print('NO')


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modDivide(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		print('Division not defined')
	else:
		return inv * a % m

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		y = z = 0
		a = ain()
		ans = 'YES'
		x = sum(a)
		yy = max(a)
		for i in range(1, n):
			y += a[i]
			y = max(0, y)
			yy = max(yy, y)
		for i in range(0, n - 1):
			z += a[i]
			z = max(0, z)
			yy = max(yy, z)
		if x > yy:
			print('YES')
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


num1 = int(input())
for i in range(num1):
	n = int(input())
	list1 = list(map(int, input().split()))
	r = sum(list1)
	sum1 = 0
	t = True
	for i in range(n - 1):
		sum1 += list1[i]
		if sum1 <= 0 or sum1 >= r:
			t = False
			print('NO')
			break
	if t:
		print('YES')


def main(n, lst):
	lst0 = lst[:-1]
	(maxx0, sum1) = (float('-inf'), float('-inf'))
	for i in range(len(lst0)):
		sum1 = max(sum1 + lst0[i], lst0[i])
		maxx0 = max(maxx0, sum1)
	lst1 = lst[1:]
	(maxx1, sum1) = (float('-inf'), float('-inf'))
	for i in range(len(lst1)):
		sum1 = max(sum1 + lst1[i], lst1[i])
		maxx1 = max(maxx1, sum1)
	maxx = max(maxx0, maxx1)
	if maxx < sum(lst):
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(main(n, lst))


import sys
input = sys.stdin.readline
I = input
t = int(input())
while t:
	n = int(I())
	ps = []
	l = list(map(int, I().split()))
	suu = sum(l)
	mx = -1
	su = 0
	for i in range(n - 1):
		su += l[i]
		if su < 0:
			su = 0
		elif su > mx:
			mx = su
	su = 0
	for i in range(1, n):
		su += l[i]
		if su < 0:
			su = 0
		elif su > mx:
			mx = su
	print
	if mx >= suu:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	t = list(map(int, input().split()))
	s = 0
	p = 0
	no = False
	for i in range(len(t)):
		s += t[i]
		p += t[len(t) - i - 1]
		if s <= 0 or p <= 0:
			no = True
			break
	if no:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	res = 'YES'
	sum_left = 0
	sum_right = 0
	for i in range(n - 1):
		sum_left += a[i]
		sum_right += a[n - i - 1]
		if sum_left <= 0 or sum_right <= 0:
			res = 'NO'
			break
	print(res)


t = int(input())
for query in range(t):
	n = int(input())
	pref = [0] * n
	suf = [0] * n
	last = [True] * n
	first = [True] * n
	l = True
	f = True
	cur = 0
	curmin = 0
	L = [int(i) for i in input().split()]
	for i in range(n - 1):
		cur += L[i]
		if cur <= curmin:
			f = False
			curmin = cur
		first[i + 1] = f
		pref[i + 1] = curmin
	cur = 0
	for i in range(n - 1, 0, -1):
		cur += L[i]
		if cur <= curmin:
			l = False
			curmin = cur
		last[i - 1] = l
		pref[i - 1] = curmin
	tr = False
	for i in range(n):
		if suf[i] + pref[i] < 0:
			tr = True
		if suf[i] + pref[i] == 0 and (not first[i] or not last[i]):
			tr = True
	if tr:
		print('NO')
	else:
		print('YES')


import math

def kadane(arr, i, j):
	maxi = -math.inf
	sumi = 0
	for k in range(i, j + 1):
		sumi = max(sumi + arr[k], arr[k])
		maxi = max(maxi, sumi)
	return maxi

def pro(arr):
	y = sum(arr)
	n = len(arr)
	op1 = kadane(arr, 0, n - 2)
	op2 = kadane(arr, 1, n - 1)
	ade = max(op1, op2)
	if y > ade:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	pro(arr)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	su = 0
	flag = 0
	ba = 0
	for i in range(n):
		if l[i] > 0:
			su += l[i]
		if l[i] <= 0:
			if su + l[i] <= 0:
				ba = -1
				su = 0
			else:
				su += l[i]
		if su >= s:
			if i == n - 1 and su == s:
				if ba == 0:
					break
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	s = sum(li)
	ans = 0
	co = 0
	d = []
	for i in range(n - 1):
		ans += li[i]
		d.append(ans)
		if ans < 0:
			ans = 0
	ans = 0
	for i in range(1, n):
		ans += li[i]
		d.append(ans)
		if ans < 0:
			ans = 0
	if s > max(d):
		print('YES')
	else:
		print('NO')


def maxSubArray(n, a):
	maxSum = a[0]
	dp = [a[0]] + [0] * (n - 1)
	for i in range(1, n):
		if a[i] > a[i] + dp[i - 1]:
			dp[i] = a[i]
		else:
			dp[i] = a[i] + dp[i - 1]
		maxSum = max(maxSum, dp[i])
	return maxSum
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(lambda x: int(x), input().split()))
	maxAdel = max(maxSubArray(n - 1, a[:-1]), maxSubArray(n - 1, a[1:]))
	print('YES') if sum(a) > maxAdel else print('NO')


def main():
	t = int(input())
	for h in range(t):
		n = int(input())
		s = [int(g) for g in input().split()]
		q1 = []
		q2 = []
		k = 0
		w = sum(s)
		for i in range(1, n):
			k += s[i]
			q1.append(k)
		k = 0
		for i in range(n - 1):
			k += s[i]
			q2.append(k)
		m1 = max(q1) - min(min(q1), 0)
		m2 = max(q2) - min(min(q2), 0)
		q = max(m1, m2)
		if w <= q:
			print('NO')
		else:
			print('YES')
main()