You are given an array of $n$ integers $a_1,a_2,\dots,a_n$.

You have to create an array of $n$ integers $b_1,b_2,\dots,b_n$ such that:   The array $b$ is a rearrangement of the array $a$, that is, it contains the same values and each value appears the same number of times in the two arrays. In other words, the multisets $\{a_1,a_2,\dots,a_n\}$ and $\{b_1,b_2,\dots,b_n\}$ are equal.

For example, if $a=[1,-1,0,1]$, then $b=[-1,1,1,0]$ and $b=[0,1,-1,1]$ are rearrangements of $a$, but $b=[1,-1,-1,0]$ and $b=[1,0,2,-3]$ are not rearrangements of $a$.  For all $k=1,2,\dots,n$ the sum of the first $k$ elements of $b$ is nonzero. Formally, for all $k=1,2,\dots,n$, it must hold $$b_1+b_2+\cdots+b_k\not=0\,.$$ 

If an array $b_1,b_2,\dots, b_n$ with the required properties does not exist, you have to print NO.


-----Input-----

Each test contains multiple test cases. The first line contains an integer $t$ ($1\le t \le 1000$) — the number of test cases. The description of the test cases follows.

The first line of each testcase contains one integer $n$ ($1\le n\le 50$)  — the length of the array $a$.

The second line of each testcase contains $n$ integers $a_1,a_2,\dots, a_n$ ($-50\le a_i\le 50$)  — the elements of $a$.


-----Output-----

For each testcase, if there is not an array $b_1,b_2,\dots,b_n$ with the required properties, print a single line with the word NO.

Otherwise print a line with the word YES, followed by a line with the $n$ integers $b_1,b_2,\dots,b_n$. 

If there is more than one array $b_1,b_2,\dots,b_n$ satisfying the required properties, you can print any of them.


-----Example-----
Input
4
4
1 -2 3 -4
3
0 0 0
5
1 -1 1 -1 1
6
40 -31 -9 0 13 -40

Output
YES
1 -2 3 -4
NO
YES
1 1 -1 1 -1
YES
-40 13 40 0 -9 -31



-----Note-----

Explanation of the first testcase: An array with the desired properties is $b=[1,-2,3,-4]$. For this array, it holds:   The first element of $b$ is $1$.  The sum of the first two elements of $b$ is $-1$.  The sum of the first three elements of $b$ is $2$.  The sum of the first four elements of $b$ is $-2$. 

Explanation of the second testcase: Since all values in $a$ are $0$, any rearrangement $b$ of $a$ will have all elements equal to $0$ and therefore it clearly cannot satisfy the second property described in the statement (for example because $b_1=0$). Hence in this case the answer is NO.

Explanation of the third testcase: An array with the desired properties is $b=[1, 1, -1, 1, -1]$. For this array, it holds:   The first element of $b$ is $1$.  The sum of the first two elements of $b$ is $2$.  The sum of the first three elements of $b$ is $1$.  The sum of the first four elements of $b$ is $2$.  The sum of the first five elements of $b$ is $1$. 

Explanation of the fourth testcase: An array with the desired properties is $b=[-40,13,40,0,-9,-31]$. For this array, it holds:   The first element of $b$ is $-40$.  The sum of the first two elements of $b$ is $-27$.  The sum of the first three elements of $b$ is $13$.  The sum of the first four elements of $b$ is $13$.  The sum of the first five elements of $b$ is $4$.  The sum of the first six elements of $b$ is $-27$.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics


Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	sums = sum(lst)
	if sums == 0:
		print('NO')
	else:
		print('YES')
		if sums < 0:
			lst.sort()
			for j in lst:
				print(j, end=' ')
			print()
		elif sums > 0:
			lst.sort(reverse=True)
			for j in lst:
				print(j, end=' ')
			print()


for i in range(int(input())):
	b = int(input())
	a = list(map(int, input().split(' ')))
	if sum(a) == 0:
		print('NO')
	elif sum(a) < 0:
		print('YES')
		e = sorted(a)
		for k in e:
			print(k, end=' ')
		print()
	else:
		print('YES')
		e = reversed(sorted(a))
		for q in e:
			print(q, end=' ')
		print()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def leftRotate(arr, d, n):
	for i in range(gcd(d, n)):
		temp = arr[i]
		j = i
		while 1:
			k = j + d
			if k >= n:
				k = k - n
			if k == i:
				break
			arr[j] = arr[k]
			j = k
		arr[j] = temp

def prefix(a):
	b = [0] * n
	b[0] = a[0]
	for i in range(1, len(a)):
		b[i] = b[i - 1] + a[i]
	return b
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = [0] * n
	b[0] = a[0]
	for i in range(1, n):
		b[i] = b[i - 1] + a[i]
	if 0 not in b:
		print('YES')
		print(*a)
	else:
		cycle = 0
		while 0 in b:
			cycle += 1
			leftRotate(a, 1, n)
			b = prefix(a)
			if cycle == n + 1:
				break
		if 0 in b:
			print('NO')
		else:
			print('YES')
			print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	ll = map(int, input().split())
	(pos, neg) = ([], [])
	for i in ll:
		if i >= 0:
			pos.append(i)
		else:
			neg.append(i)
	(pos_sum, neg_sum) = (sum(pos), sum(neg) * -1)
	if pos_sum == neg_sum:
		print('NO')
	else:
		print('YES')
		pos = sorted(pos, reverse=True)
		neg = sorted(neg)
		if pos_sum > neg_sum:
			print(' '.join(map(str, pos + neg)))
		else:
			print(' '.join(map(str, neg + pos)))


test = int(input())
for t in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			l.sort(reverse=True)
			print(*l)
		else:
			l.sort()
			print(*l)


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

def arp(arr):
	return ' '.join([str(i) for i in arr])
from collections import deque, Counter
from math import ceil, sqrt, log2, log, floor

def check(arr):
	for i in range(1, len(arr)):
		tem = sum(arr[:i])
		if tem == 0:
			return False
	return True
for _ in range(int(input())):
	(n,) = rl()
	arr = rl()
	su = sum(arr)
	if arr.count(0) == n:
		print('NO')
	elif su == 0:
		print('NO')
	else:
		ans = sorted(arr, reverse=True)
		for _ in range(n):
			f = check(ans)
			if f:
				print('YES')
				print(arp(ans))
				break
			else:
				ans = ans[1:] + ans[:1]
		if not f:
			print('NO')


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


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	n = ii()
	a = il()
	a.sort()
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	else:
		print('YES')
		print(*a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	else:
		x = sum(l)
		print('YES')
		if x > 0:
			l.sort(reverse=True)
		else:
			l.sort()
		print(*l)


n = int(input())
cases = []
for i in range(n):
	int(input())
	cases.append(list(map(int, input().split())))
for i in range(n):
	s = sum(cases[i])
	if s > 0:
		print('YES')
		print(' '.join((str(j) for j in sorted(cases[i], reverse=True))))
	if s < 0:
		print('YES')
		print(' '.join((str(j) for j in sorted(cases[i], reverse=False))))
	if s == 0:
		print('NO')


from sys import stdout, stdin
from io import IOBase, BytesIO
from os import read, write, fstat
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 = read(self._fd, max(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, size: int=...):
		while self.newlines == 0:
			b = read(self._fd, max(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:
			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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		u = []
		v = []
		w = []
		for i in range(n):
			if a[i] < 0:
				u.append(a[i])
			if a[i] > 0:
				v.append(a[i])
			if a[i] == 0:
				w.append(0)
		j = [str(x) for x in u]
		k = [str(x) for x in v]
		l = [str(x) for x in w]
		if sum(u) + sum(v) < 0:
			s = ' '.join(j) + ' ' + ' '.join(k) + ' ' + ' '.join(l)
		else:
			s = ' '.join(k) + ' ' + ' '.join(j) + ' ' + ' '.join(l)
		print(s)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	total = sum(a)
	if total == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if total > 0:
			print(*a[::-1])
		else:
			print(*a)


t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	for i in l:
		s += i
	if s == 0:
		print('NO')
	else:
		l.sort()
		if s > 0:
			l.reverse()
		a = ''
		for i in l:
			a += str(i) + ' '
		print('YES')
		print(a.strip())


T = int(input())
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	summ = sum(A)
	if summ == 0:
		print('NO')
	else:
		pos = []
		neg = []
		zeros = []
		for x in A:
			if x == 0:
				zeros.append(x)
			elif x < 0:
				neg.append(x)
			else:
				pos.append(x)
		if summ > 0:
			res = pos + zeros + neg
		else:
			res = neg + zeros + pos
		print('YES')
		for x in res:
			print(x, end=' ')
		print()


t = int(input())
for h in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if sum(a) == 0:
		print('No')
	else:
		print('Yes')
		if sum(a) > 0:
			print(*a[::-1])
		else:
			print(*a)


for x in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	totsum = sum(l)
	pos = []
	neg = []
	new = []
	if totsum == 0:
		print('NO')
	else:
		for y in l:
			if y < 0:
				neg.append(y)
			else:
				pos.append(y)
		if totsum > 0:
			new = sorted(pos, reverse=True)
			new.extend(neg)
			print('YES')
			print(*new, end='\n')
		else:
			neg.extend(pos)
			print('YES')
			print(*neg, end='\n')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	(pos, neg, zero) = ([], [], [])
	for i in a:
		if i > 0:
			pos.append(i)
		elif i < 0:
			neg.append(i)
		else:
			zero.append(i)
	b = []
	if sum(pos) > abs(sum(neg)):
		b = pos + neg + zero
	else:
		b = neg + pos + zero
	print('YES')
	print(*b)


repeat = int(input())
traversal = 0
result_y_n = []
result_yes_array = []
for again in range(repeat):
	loose = input()
	a = list(map(int, input().split()))
	is_true = False
	adder = 0
	if sum(a) == 0:
		result_y_n.append('NO')
	else:
		b = a
		b.sort()
		for k in b:
			adder += k
			if adder == 0:
				is_true = True
				break
		if is_true:
			b.sort(reverse=True)
		result_y_n.append('YES')
		result_yes_array.append(b)
coresponding = 0
for s_result in result_y_n:
	print(s_result)
	if s_result == 'YES':
		for another in result_yes_array[coresponding]:
			print(another, end=' ')
		print()
		coresponding += 1


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
count = inp()
for _ in range(count):
	k = inp()
	anums = inlt()
	negative = []
	positive = []
	zeros = 0
	for val in anums:
		if val > 0:
			positive.append(val)
		elif val < 0:
			negative.append(val)
		else:
			zeros += 1
	p = sum(positive)
	n = sum(negative)
	if p == abs(n):
		print('NO')
	else:
		print('YES')
		if p > abs(n):
			print(*positive + negative + [0] * zeros, sep=' ')
		else:
			print(*negative + positive + [0] * zeros, sep=' ')


for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) < 0:
		a1 = sorted(a)
		print('YES')
		for i in range(n):
			print(a1[i], end=' ')
		print()
	elif sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a1 = sorted(a)
		a1 = a1[::-1]
		for i in range(n):
			print(a1[i], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	elif sum(arr) > 0:
		print('YES')
		arr = sorted(arr, reverse=True)
		print(' '.join(list(map(str, arr))))
	elif sum(arr) < 0:
		print('YES')
		arr = sorted(arr)
		print(' '.join(list(map(str, arr))))


t = int(input())
for _ in range(t):
	n = int(input())
	arrIn = list(map(int, input().split()))
	numNos = 0
	for arr in [sorted(arrIn), sorted(arrIn, reverse=True)]:

		def check():
			p = [0]
			for num in arr:
				curr = p[-1] + num
				p.append(curr)
				if curr == 0:
					return False
			return True
		if check():
			print('YES')
			print(' '.join(map(str, arr)))
			break
		else:
			numNos += 1
	if numNos == 2:
		print('NO')


for _ in range(0, int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	s = sum(v)
	if s == 0:
		print('NO')
	else:
		print('YES')
		print(*sorted(v)[::-1 + 2 * (s < 0)])


for _ in range(int(input().strip())):
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		a.sort()
		for el in reversed(a):
			print(el, end=' ')
		print()
	else:
		print('YES')
		a.sort()
		for el in a:
			print(el, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort(reverse=sum(a) > 0)
	print('YES\n' + ' '.join((str(i) for i in a)) if sum(a) != 0 else 'NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	s = 0
	for i in range(0, n):
		s += L[i]
	if s == 0:
		print('NO')
	else:
		L.sort()
		s = 0
		check = True
		for i in range(0, n):
			s += L[i]
			if s == 0:
				check = False
				break
		if check:
			print('YES')
			print(*L)
		else:
			print('YES')
			M = L[::-1]
			print(*M)


t = int(input())
for _ in range(t):
	(n, a) = (int(input()), [int(i) for i in input().split()])
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		gt0 = [i for i in a if i > 0]
		lt0 = [i for i in a if i < 0]
		res = gt0 + lt0 if s > 0 else lt0 + gt0
		res += [0] * (n - len(gt0) - len(lt0))
		print(*res)


t = int(input())
for qwe in range(t):
	n = int(input())
	l = [int(j) for j in input().split()]
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		ans = sorted(l)
		print('YES')
		if s > 0:
			print(*ans[::-1])
		else:
			print(*ans)


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = input().split()
	pos = []
	neg = []
	zer = 0
	s = 0
	for w in a:
		v = int(w)
		if v < 0:
			neg.append(w)
		elif v > 0:
			pos.append(w)
		else:
			zer += 1
		s += v
	if s == 0:
		ans.append('NO')
	else:
		ans.append('YES')
		z = ' '.join(['0'] * zer)
		if s > 0:
			ret = ' '.join([' '.join(pos), z, ' '.join(neg)])
		else:
			ret = ' '.join([' '.join(neg), z, ' '.join(pos)])
		ans.append(ret)
print('\n'.join(ans))


for _ in range(int(input())):
	n = int(input())
	nums = [int(i) for i in input().split()]
	total = sum(nums)
	if total:
		print('YES')
		if total > 0:
			print(' '.join([str(i) for i in sorted(nums, reverse=True)]))
		else:
			print(' '.join([str(i) for i in sorted(nums)]))
	else:
		print('NO')


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().strip().split()))
	if sum(a) == 0:
		print('NO')
	else:
		a2 = []
		a3 = []
		a1 = []
		for i in a:
			if i < 0:
				a1.append(i)
			elif i == 0:
				a2.append(i)
			else:
				a3.append(i)
		if abs(sum(a1)) == sum(a3):
			print('NO')
		elif abs(sum(a1)) > sum(a3):
			a4 = a1 + a3 + a2
			print('YES')
			print(*a4)
		else:
			a4 = a3 + a1 + a2
			print('YES')
			print(*a4)


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	if sum(lst) == 0:
		print('NO')
		return 0
	print('YES')
	if sum(lst) > 0:
		lst.sort(reverse=True)
	else:
		lst.sort()
	print(*lst)
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = sum(a)
	if s == 0:
		print('NO')
	elif s > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	else:
		a.sort()
		print('YES')
		print(*a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	if sum(a) == 0:
		print('NO')
	else:
		c = d = 0
		for i in range(n):
			if a[i] < 0:
				c += a[i]
			elif a[i] > 0:
				d += a[i]
		if abs(c) > d:
			a.sort()
		else:
			a.sort(reverse=True)
		print('YES')
		print(*a)


import sys
import os
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')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def check(lst):
	summ = 0
	for i in lst:
		summ += i
		if summ == 0:
			return False
	return True
from random import shuffle as sh

def solve(n, lst):
	if sum(lst) == 0:
		return 'NO'
	value = False
	while value == False:
		sh(lst)
		value = check(lst)
	print('YES')
	return ' '.join(list(map(str, lst)))
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(solve(n, lst))


def process():
	n = int(input())
	li = list(map(int, input().split()))
	if sum(li) == 0:
		print('NO')
		return
	li.sort()
	s = li[0]
	flag = 0
	for i in range(1, n):
		if s == 0:
			flag = 1
		s += li[i]
	if s == 0 or flag == 0:
		print('YES')
		for i in li:
			print(i, end=' ')
		print()
		return
	li.sort(reverse=True)
	s = li[0]
	flag = 0
	for i in range(1, n):
		if s == 0:
			flag = 1
		s += li[i]
	if s == 0 or flag == 0:
		print('YES')
		for i in li:
			print(i, end=' ')
		print()
		return
	print('NO')
	return
tests = int(input())
for i in range(tests):
	process()


t = int(input())

def solve(l):
	s = 0
	for i in range(len(l)):
		s += l[i]
		if s == 0:
			return False
	print('YES')
	print(' '.join(map(str, l)))
	return True
for tt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if solve(l):
		continue
	l = l[::-1]
	if solve(l):
		continue
	print('NO')


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def bs2(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def bs(arr, l, r, x):
	if x < arr[0]:
		return -1
	if x > arr[len(arr) - 1]:
		return len(arr)
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] <= x:
			l = mid + 1
		elif arr[mid] > x:
			r = mid - 1
	pos = l
	while pos < len(arr) and arr[pos] <= x:
		pos += 1
	return pos

def solve():
	n = iinp()
	arr = intl()
	if sum(arr) != 0:
		print('YES')
		if sum(arr) > 0:
			arr.sort(reverse=True)
			print(*arr)
		else:
			arr.sort()
			print(*arr)
	else:
		print('NO')
for _ in range(iinp()):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = [int(e) for e in input().split()]
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		arr.sort()
		if sum(arr) > 0:
			arr.reverse()
		print(*arr)


T = int(input())
for z in range(T):
	n = int(input())
	s = input()
	add = 0
	neg = list()
	pos = list()
	for e in s.split():
		e = int(e)
		add += e
		if e < 0:
			neg.append(e)
		else:
			pos.append(e)
	if add == 0:
		print('NO')
	elif add > 0:
		print('YES')
		pos.sort(reverse=True)
		for e in pos:
			print(e, end=' ')
		for e in neg:
			print(e, end=' ')
		print('')
	else:
		print('YES')
		for e in neg:
			print(e, end=' ')
		for e in pos:
			print(e, end=' ')
		print('')


test_cases = int(input())
for case in range(test_cases):
	lenght = int(input())
	array = [int(i) for i in input().split()]
	suma = sum(array)
	if suma == 0:
		print('NO')
	else:
		print('YES')
		if suma < 0:
			array.sort()
		else:
			array.sort(reverse=True)
		array_str = [str(i) for i in array]
		print(' '.join(array_str))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		print('YES')
		l.sort()
		s = t = 0
		for i in range(n):
			s += l[i]
			if s == 0:
				t = 1
				break
		if t == 1:
			print(*sorted(l, reverse=True))
			continue
		print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		if sum(arr) > 0:
			arr.sort(reverse=True)
			print(*arr)
		else:
			arr.sort()
			print(*arr)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sum_value = sum(a)
	if sum_value == 0:
		print('NO')
		continue
	pos = [i for i in a if i > 0]
	neg = [i for i in a if i < 0]
	if sum_value > 0:
		b = pos + neg
	else:
		b = neg + pos
	x = n - len(pos) - len(neg)
	for i in range(x):
		b.append(0)
	print('YES')
	for i in b:
		print(i, end=' ')
	print()


def ans_if_list(ans):
	if isinstance(ans, str):
		return ans
	elif isinstance(ans, int):
		return ans
	else:
		return ' '.join((str(ans[i]) for i in range(len(ans))))
t = int(input())
for q in range(t):
	l = int(input())
	ls = list(map(int, input().split()))
	s = sum(ls)
	if s > 0:
		ans = 'YES'
		ls = sorted(ls, reverse=True)
		ans_ls = ans_if_list(ls)
		print(ans)
		print(ans_ls)
	elif s == 0:
		ans = 'NO'
		print(ans)
	elif s < 0:
		ans = 'YES'
		ls = sorted(ls)
		ans_ls = ans_if_list(ls)
		print(ans)
		print(ans_ls)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

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

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

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

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	n = scanner()
	a = get_list()
	if sum(a) < 0:
		print('YES')
		print(*sorted(a))
	elif sum(a) == 0:
		print('NO')
	else:
		print('YES')
		print(*sorted(a, reverse=True))
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(pos, neg) = ([], [])
	(flag, res) = (0, 0)
	s = sum(a)
	if s == 0:
		flag = 1
		print('NO')
	if flag == 0:
		for i in range(n):
			if a[i] > 0:
				pos.append(a[i])
			else:
				neg.append(a[i])
		a1 = sum(pos)
		b1 = abs(sum(neg))
		if a1 > b1:
			pos.sort()
			neg.sort(reverse=True)
			print('YES')
			s = pos + neg
			for i in range(len(s)):
				print(s[i], end=' ')
			print()
		else:
			pos.sort(reverse=True)
			neg.sort()
			print('YES')
			s = neg + pos
			for i in range(len(s)):
				print(s[i], end=' ')
			print()


def solve():
	size = input()
	array = list(map(int, input().split()))
	polSum = 0
	otrSum = 0
	for it in array:
		if it > 0:
			polSum += it
		else:
			otrSum += it
	if polSum + otrSum == 0:
		print('NO')
		return
	elif abs(polSum) < abs(otrSum):
		array.sort()
	else:
		array.sort(reverse=True)
	print('YES')
	print(*array)
tests = int(input())
while tests > 0:
	solve()
	tests -= 1


def sol():
	testcase = int(input())
	for i in range(testcase):
		arrlen = int(input())
		arr = list(map(int, input().split()))
		arr.sort()
		a = 0
		for j in range(arrlen):
			a += arr[j]
			if a == 0:
				a = 0
				break
		if a == 0:
			arr.reverse()
			for k in range(arrlen):
				a += arr[k]
				if a == 0:
					a = 0
					print('NO')
					break
		if a != 0:
			print('YES')
			print(*arr)
sol()


for t in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	n1 = sorted(nums)
	n2 = sorted(nums, reverse=True)
	a1 = a2 = True
	s1 = s2 = 0
	for i in range(n):
		s1 += n1[i]
		s2 += n2[i]
		if s1 == 0:
			a1 = False
		if s2 == 0:
			a2 = False
		if a1 == False and a2 == False:
			break
	if a1:
		print('YES')
		print(*n1)
	elif a2:
		print('YES')
		print(*n2)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		a.sort(reverse=s > 0)
		print('YES')
		print(*a, sep=' ')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

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

def inv_mod(n):
	return pow(n, mod - 2, mod)

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

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
for _ in range(val()):
	n = val()
	l = sorted(li())
	if sum(l):
		print('YES')
		negs = []
		pos = []
		zero = 0
		for i in l:
			if i > 0:
				pos.append(i)
			elif i < 0:
				negs.append(i)
			else:
				zero += 1
		if abs(sum(negs)) > sum(pos):
			l = negs[:] + pos[:]
		else:
			l = pos[:] + negs[:]
		l += [0] * zero
		print(*l)
	else:
		print('NO')


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import heapify, heappop, heappush
from statistics import median, mean
from math import gcd, sqrt, floor, factorial, ceil, log2, log10, log
import fractions
import copy
from copy import deepcopy
import sys
import io
sys.setrecursionlimit(10 ** 8)
import math
import os
import bisect
import collections
mod = pow(10, 9) + 7
import random
from random import random, randint, randrange
from time import time

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def normalncr(n, r):
	r = min(r, n - r)
	count = 1
	for i in range(n - r, n + 1):
		count *= i
	for i in range(1, r + 1):
		count //= i
	return count
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

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

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

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

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
	return (b, a)

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return [i] + prime_factors(n // i)
	return [n]

def p(a):
	if type(a) == str:
		print(a + '\n')
	else:
		print(str(a) + '\n')

def ps(a):
	if type(a) == str:
		print(a)
	else:
		print(str(a))

def kth_no_not_div_by_n(n, k):
	return k + (k - 1) // (n - 1)
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'

def fun(i, l):
	for j in l:
		if abs(i[0] - j[0]) + abs(i[1] - j[1]) > k:
			return 0
	return 1
t = int(input())
for i in range(t):
	n = int(input())
	l = get_list()
	pos = [i for i in l if i > 0]
	neg = [i for i in l if i < 0]
	zeros = [i for i in l if i == 0]
	poss = sum(pos)
	negs = abs(sum(neg))
	if poss > negs:
		print(yc)
		print(*pos + neg + zeros)
	elif poss < negs:
		print(yc)
		print(*neg + pos + zeros)
	else:
		print(nc)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		(neg, pos) = (0, 0)
		for i in arr:
			if i < 0:
				neg -= i
			else:
				pos += i
		if pos > neg:
			arr.sort(reverse=True)
		else:
			arr.sort()
		print('YES')
		print(*arr)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	sa = sum(a)
	if sa == 0:
		print('NO')
	elif sa > 0:
		print('YES')
		print(*sorted(a, reverse=True))
	else:
		print('YES')
		print(*sorted(a))


for _ in range(int(input())):
	lo = input()
	l = [int(x) for x in input().split()]
	s = sum(l)
	if s == 0:
		print('NO')
	elif s > 0:
		a = sorted(l, reverse=True)
		print('YES')
		print(*a)
	else:
		ds = sorted(l)
		print('YES')
		print(*ds)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	summ = 0
	for i in a:
		summ += i
	if summ == 0:
		print('NO')
	else:
		print('YES')
		positive = []
		negative = []
		for i in a:
			if i > 0:
				positive.append(i)
			else:
				negative.append(i)
		positive.sort()
		negative.sort()
		if summ > 0:
			a = positive + negative
		else:
			a = negative + positive
		summ = 0
		for i in range(n):
			summ += a[i]
			if summ == 0:
				summ -= a[i]
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				summ += a[i]
		a = list(map(str, a))
		print(' '.join(a))


t = int(input())
while t > 0:
	t -= 1
	k = int(input())
	s = list(map(int, input().split()))
	x = sum(s)
	if sum(s) == 0:
		print('NO')
	else:
		s.sort()
		if x > 0:
			s.reverse()
		print('YES')
		for i in s:
			print(i, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
		continue
	print('YES')
	if sum(arr) > 0:
		arr.sort(reverse=True)
		print(*arr)
	else:
		arr.sort()
		print(*arr)


from random import sample

def solucion(n, heroes):
	suma = 0
	length = len(heroes)
	for i in range(length):
		suma = heroes[i] + suma
	if suma == 0:
		return 'NO'
	else:
		resultado = ''
		suma2 = 1
		salir = False
		while suma2 != 0 and salir == False:
			while suma2 != 0 and salir == False:
				suma2 = 0
				for i in range(length):
					suma2 = heroes[i] + suma2
					if suma2 == 0:
						heroes = sample(heroes, length)
						suma2 = 1
						break
					if i == length - 1:
						salir = True
						break
		resultado = 'YES\n'
		for i in range(length):
			if i == 0:
				resultado = resultado + '' + str(heroes[i])
			else:
				resultado = resultado + ' ' + str(heroes[i])
		return resultado
n = int(input())
myList = list()
while n != 0:
	n1 = int(input())
	heroes = list(map(int, input().split(' ')))
	myList.append(solucion(n, heroes))
	n = n - 1
longList = len(myList)
for i1 in range(longList):
	print(myList[i1])


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().split()))
	z = []
	pos = []
	neg = []
	for j in a:
		if j < 0:
			neg.append(j)
		elif j > 0:
			pos.append(j)
		else:
			z.append(0)
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if sum(a) < 0:
			for k in neg:
				print(k, end=' ')
			for h in pos:
				print(h, end=' ')
			for p in z:
				print(p, end=' ')
			print('')
		else:
			for h in pos:
				print(h, end=' ')
			for k in neg:
				print(k, end=' ')
			for p in z:
				print(p, end=' ')
			print('')


for _ in range(int(input())):
	n = int(input())
	ls = sorted(list(map(int, input().split())))
	ar = []
	j = n - 1
	i = 0
	if sum(ls) > 0:
		ls = list(reversed(ls))
	sm = 0
	k = 0
	for i in range(n):
		sm += ls[i]
		if sm != 0:
			k += 1
		else:
			break
	if k == n:
		print('YES')
		print(*ls)
	else:
		print('NO')


cases = int(input())
for _ in range(cases):
	n = int(input())
	c = list(map(int, input().split()))
	if sum(c) == 0:
		print('NO')
	else:
		print('YES')
		if sum(c) > 0:
			print(*sorted(c)[::-1])
		else:
			print(*sorted(c))


def ps(i):
	ps = [0] * len(i)
	ps[0] = i[0]
	for j in range(1, len(i)):
		ps[j] = ps[j - 1] + i[j]
	for j in ps:
		if j == 0:
			return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		x = sorted(a, reverse=True)
		if ps(x):
			print(*x)
		else:
			print(*x[::-1])


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

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

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

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		if sum(a) == 0:
			print('NO')
		else:
			print('YES')
			if sum(a) > 0:
				a.sort(reverse=True)
				s = 0
				for i in range(n):
					s += a[i]
					if s == 0:
						(a[i], a[-1]) = (a[-1], a[i])
						s -= a[-1]
						s += a[i]
			else:
				a.sort()
				s = 0
				for i in range(n):
					s += a[i]
					if s == 0:
						(a[i], a[-1]) = (a[-1], a[i])
						s -= a[-1]
						s += a[i]
			print(*a)
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	ls = list(map(int, input().split()))
	if sum(ls) == 0:
		print('NO')
	else:
		print('YES')
		if sum(ls) > 0:
			ls.sort(reverse=True)
		else:
			ls.sort()
		print(*ls)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def pw(a, b, md):
	result = 1
	while b > 0:
		if b % 2 == 1:
			result *= a
			result %= md
		a *= a
		a %= md
		b //= 2
	return result % md

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		if sum(ar) == 0:
			print('NO')
		else:
			print('YES')
			(one, two) = (0, 0)
			for i in ar:
				if i < 0:
					one += i
				else:
					two += i
			if abs(one) > abs(two):
				print(*sorted(ar))
			else:
				print(*sorted(ar, reverse=True))
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')
threading.Thread(target=main).start()


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	if sum(lst) == 0:
		print('NO')
	else:
		print('YES')
		if sum(lst) < 0:
			lst.sort()
		else:
			lst.sort(reverse=True)
		print(*lst)


t = int(input())
while t:
	len_array = int(input())
	array = input()
	array = array.split(' ')
	array = [int(x) for x in array]
	p = sum(array)
	if p == 0:
		print('NO')
	else:
		array.sort()
		a = filter(lambda x: x > 0, array)
		b = filter(lambda x: x < 0, array)
		a = sum(a)
		b = sum(b)
		if b * -1 < a:
			array.reverse()
		print('YES')
		print(*array, sep=' ')
	t -= 1


from random import *
for _ in ' ' * int(input()):
	input()
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	else:
		print('YES')
	p = 0
	while p == 0:
		shuffle(a)
		for x in a:
			p += x
			if p == 0:
				break
	print(*a)


import sys
t = sys.stdin.readline()
for _ in range(0, int(t)):
	n = sys.stdin.readline()
	a = [int(x) for x in sys.stdin.readline().split()]
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	elif sum(a) < 0:
		a.sort()
		print('YES')
		print(*a)
a = [1, 2, 3, 7]
a.sort(reverse=True)


import math
t = int(input())
for t1 in range(t):
	n = int(input())
	a = [int(n1) for n1 in input().split()]
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		b = sorted(a, reverse=True)
		print(*b)
	else:
		print('YES')
		b = sorted(a)
		print(*b)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if sum(a) > 0:
			a.sort(reverse=1)
			print(*a)
		else:
			a.sort()
			print(*a)


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	check1 = 1
	check2 = 1
	for i in range(len(a)):
		if sum(a[:i + 1]) == 0:
			check1 = 0
		if sum(a[::-1][:i + 1]) == 0:
			check2 = 0
	if check1 == 0 and check2 == 0:
		print('NO')
	elif check1 == 1:
		print('YES', *a)
	else:
		print('YES', *a[::-1])


from math import gcd
from bisect import bisect_left, bisect_right
from itertools import combinations
from itertools import permutations
from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop, nsmallest
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

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

def si():
	return str(input())

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

def li1():
	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 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		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 binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def subarray(A):
	r = set()
	p = {0}
	for x in A:
		p = {x | y for y in p} | {x}
		r |= p
	return len(r)

def setBitNumber(n):
	n |= n >> 1
	n |= n >> 2
	n |= n >> 4
	n |= n >> 8
	n |= n >> 16
	n = n + 1
	return n >> 1

def countSetBits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count
for _ in range(int(input())):
	n = int(input())
	neg = []
	pos = []
	z = []
	l = li1()
	for i in l:
		if i < 0:
			neg.append(i)
		elif i == 0:
			z.append(0)
		else:
			pos.append(i)
	ans = []
	if sum(l) == 0:
		print('NO')
		continue
	print('YES')
	if abs(sum(neg)) > sum(pos):
		print(*neg + pos + z)
	elif sum(pos) > abs(sum(neg)):
		print(*pos + neg + z)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		arr.sort()
		for i in range(n - 1):
			if sum(arr[:i + 1]) == 0:
				arr.reverse()
		print(' '.join(map(str, arr)))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	if sum(b) == 0:
		print('NO')
	else:
		print('YES')
		S = 0
		for i in range(n):
			S += b[i]
			if S == 0:
				b = b[::-1]
				break
		print(*b)


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

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import time
start_time = time.time()
import collections as col
import math
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	A = getInts()
	s = sum(A)
	if s == 0:
		print('NO')
		return
	print('YES')
	pos = []
	neg = []
	zeroes = []
	for a in A:
		if a > 0:
			pos.append(a)
		elif a < 0:
			neg.append(a)
		else:
			zeroes.append(a)
	if s < 0:
		print(*list(neg + pos + zeroes))
		return
	print(*list(pos + neg + zeroes))
	return
for _ in range(getInt()):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	b.sort()
	b.reverse()
	j = 0
	s = 0
	f = 0
	if sum(b) == 0:
		f = 1
	while j < n:
		s += b[j]
		if s == 0:
			b.reverse()
			break
		j += 1
	if f == 1:
		print('NO')
	else:
		print('YES')
		print(*b)


import random
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ans = [int(x) for x in input().split()]
	z = sum(ans)
	if z == 0:
		print('NO')
	else:
		print('YES')
		s = 0
		fl = 1
		for x in ans:
			s += x
			if s == 0:
				fl = 0
		while fl == 0:
			random.shuffle(ans)
			fl = 5
			s = 0
			for x in ans:
				s += x
				if s == 0:
					fl = 0
		print(*ans)


from math import *
t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		s = 0
		b = []
		flag = 1
		for i in range(n):
			s += a[i]
			if s == 0:
				flag = 0
				break
		if flag:
			print(*a)
		else:
			a = a[-1::-1]
			print(*a)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	flag1 = True
	flag2 = True
	flag3 = True
	ans = 0
	for i in s:
		ans += i
		if ans == 0:
			flag1 = False
			break
	if flag1:
		print('YES')
		print(*s)
		continue
	s.sort()
	for i in s:
		ans += i
		if ans == 0:
			flag2 = False
			break
	if flag2:
		print('YES')
		print(*s)
		continue
	s.reverse()
	for i in s:
		ans += i
		if ans == 0:
			flag3 = False
			break
	if flag3:
		print('YES')
		print(*s)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s < 0:
		print('YES')
		print(*sorted(a))
	elif s > 0:
		print('YES')
		print(*sorted(a, reverse=True))
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
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()
		s = sum(a)
		if s == 0:
			rr.append('NO')
		else:
			rr.append('YES')
			if s > 0:
				r = sorted(a, reverse=True)
			else:
				r = sorted(a)
			rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(l) > 0:
			for i in range(len(l) - 1, -1, -1):
				print(l[i], end=' ')
			print()
		else:
			print(*l)


from copy import copy
from math import inf
from collections import defaultdict

def main():
	for _ in range(int(input())):
		n = int(input())
		a = sorted(map(int, input().split()))
		if sum(a) == 0:
			print('NO')
		else:
			print('YES')
			s = 0
			ans = -1
			for v in a:
				s += v
				if s == 0:
					ans = a[::-1]
					break
			if ans == -1:
				print(*a)
			else:
				print(*ans)
main()


import random
for i in range(int(input())):
	l = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		s = arr[0]
		i = 0
		while i < l - 1:
			if s + arr[i + 1] == 0 or arr[0] == 0:
				i = 0
				random.shuffle(arr)
				s = arr[0]
			else:
				s += arr[i + 1]
				i += 1
		print(*arr)


t = int(input())
for e in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	if sum(array) == 0:
		print('NO')
	else:
		array.sort()
		positive = [a for a in array if a > 0]
		negative = [b for b in array if b <= 0]
		if positive and negative:
			if sum(positive) > -sum(negative):
				print('YES')
				print(''.join([str(a) + ' ' for a in positive]) + ''.join([str(b) + ' ' for b in negative]))
			else:
				print('YES')
				print(''.join([str(a) + ' ' for a in negative]) + ''.join([str(b) + ' ' for b in positive]))
		elif positive:
			print('YES')
			print(''.join([str(a) + ' ' for a in positive]))
		elif negative:
			print('YES')
			print(''.join([str(a) + ' ' for a in negative]))
		else:
			print('NO')
			continue


for i in range(int(input())):
	n = int(input())
	l = [int(s) for s in input().split()]
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		positive_sum = 0
		negative_sum = 0
		zeros = []
		positives = []
		negatives = []
		for elem in l:
			if elem == 0:
				zeros.append(elem)
			elif elem > 0:
				positives.append(elem)
				positive_sum += elem
			else:
				negatives.append(elem)
				negative_sum += elem
		if abs(negative_sum) > positive_sum:
			print(*negatives + positives + zeros)
		else:
			print(*positives + negatives + zeros)


import bisect
for _ in range(int(input())):
	n = int(input())
	ar = [int(i) for i in input().split()]
	if sum(ar) == 0:
		print('NO')
	else:
		ar.sort()
		k = bisect.bisect_right(ar, -1)
		a1 = ar[:k]
		a2 = ar[k:]
		if abs(sum(a1)) > abs(sum(a2)):
			ar = a1 + a2[::-1]
		else:
			ar = a2[::-1] + a1
		print('YES')
		for i in ar:
			print(i, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = list(a)
	b = []
	s = 0
	if sum(a) == 0:
		print('NO')
	else:
		for value in sorted(c):
			if value < 0:
				s += value
				b.append(value)
				a.remove(value)
			else:
				break
		print('YES')
		a.sort()
		b.sort()
		if sum(a) > abs(sum(b)):
			print(*reversed(a))
			print(*b)
		else:
			print(*reversed(b))
			print(*a)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	a.sort()
	if sum(a) > 0:
		a.reverse()
	print('YES')
	ans = []
	for i in a:
		ans.append(str(i))
	print(' '.join(ans))


for i in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		a = sorted(a, reverse=s > 0)
		print('YES')
		print(*a)


t = int(input())
for i in range(t):
	in1 = input()
	in2 = input().split()
	in2 = list(map(int, in2))
	k = ' '
	s = sum(in2)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			in2.sort(reverse=True)
		else:
			in2.sort()
		listToStr = ' '.join(map(str, in2))
		print(listToStr)


naborov = int(input())
sets = []
for _ in range(naborov):
	input()
	l = input().split()
	sets.append([int(ll) for ll in l])

def check(s):
	summa = sum(s)
	if summa == 0:
		return ('NO', None)
	elif summa > 0:
		s.sort(reverse=True)
	else:
		s.sort()
	return ('YES', s)
for s in sets:
	ch = check(s)
	print(ch[0])
	if ch[0] == 'YES':
		print(' '.join([str(s) for s in ch[1]]))


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	if sum(x) == 0:
		print('NO')
		continue
	elif sum(x) > 0:
		x.sort(reverse=True)
		print('YES')
		print(*x, sep=' ')
	else:
		x.sort()
		print('YES')
		print(*x, sep=' ')


for _ in ' ' * int(input()):
	n = int(input())
	a = sorted(list(map(int, input().split())))[::-1]
	p = []
	ne = []
	for i in range(n):
		if a[i] >= 0:
			p.append(a[i])
		else:
			ne.append(a[i])
	p.sort()
	p = p[::-1]
	ne.sort()
	if sum(a) != 0:
		print('YES')
		if sum(p) > abs(sum(ne)):
			print(*p, *ne)
		else:
			print(*ne, *p)
	else:
		print('NO')


import sys, string
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi

def input():
	return sys.stdin.readline()[:-1]
from bisect import bisect_left, bisect_right
from operator import add
MOD = int(1000000000.0) + 7
INF = float('inf')

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if sum(a) > 0:
		a.reverse()
	if sum(a) == 0:
		print('NO')
		return
	print('YES')
	print(*a)
T = 1
T = int(input())
for case in range(1, T + 1):
	ans = solve()


n_sets = int(input())
for i in range(n_sets):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	apos = [x for x in a if x > 0]
	aneg = [x for x in a if x < 0]
	n0 = a.count(0)
	if sum(a) == 0 or a[0] == a[-1] == 0:
		print('NO')
	else:
		print('YES')
		if abs(sum(apos)) > abs(sum(aneg)):
			print(*apos, *aneg, *[0] * n0)
		else:
			print(*aneg, *apos, *[0] * n0)


t = int(input())

def solve():
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr = sorted(arr, reverse=False)
	s = arr[0]
	for i in range(1, len(arr)):
		if s == 0:
			break
		s += arr[i]
	if s != 0:
		print('YES')
		print(*arr)
	else:
		s = arr[len(arr) - 1]
		for i in range(len(arr) - 2, -1, -1):
			if s == 0:
				break
			s += arr[i]
		if s != 0:
			print('YES')
			print(*list(reversed(arr)), sep=' ')
		else:
			print('NO')
while t:
	solve()
	t -= 1


from sys import stdin
input = stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
		return
	if s < 0:
		a.sort()
	else:
		a.sort(reverse=True)
	print('YES')
	print(' '.join(map(str, a)))
t = int(input())
for _ in range(t):
	solve()


T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	s = sum(A)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			B = sorted(A, reverse=True)
		else:
			B = sorted(A)
		print(' '.join(map(str, B)))


for _ in range(int(input())):
	n = int(input())
	d = list((int(i) for i in input().split()))
	if sum(d) == 0:
		print('NO')
	else:
		print('YES')
		if sum(d) > 0:
			d.sort(reverse=True)
		else:
			d.sort()
		print(*d, sep=' ')


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


import math
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			print(*sorted(l, reverse=True))
		else:
			print(*sorted(l))


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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')
main()

def test():
	n = int(input())
	l = list(map(int, input().split()))
	r = []
	if sum(l) == 0:
		print('NO')
	else:
		l.sort()
		neg = [i for i in l if i < 1]
		pos = [i for i in l if i > 0]
		if abs(sum(neg)) > sum(pos):
			r = neg + pos
		else:
			r = pos + neg
		print('YES')
		print(*r)
t = int(input())
for _ in range(t):
	test()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) > 0:
		l.sort(reverse=True)
	else:
		l.sort()
	if l[0] == 0:
		l = l[1:]
		l.append(0)
	cs = 0
	b = True
	for i in l:
		cs += i
		if cs == 0:
			b = False
			break
	if b:
		print('YES')
		for i in l:
			print(i, end=' ')
		print()
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	Sum = sum(a)
	if Sum == 0:
		print('NO')
		continue
	print('YES')
	if Sum > 0:
		print(*sorted(a, reverse=True))
		continue
	print(*sorted(a))


for x in [*open(0)][2::2]:
	a = list(map(int, x.split()))
	s = sum(a)
	if s == 0:
		print('NO')
		continue
	print('YES')
	print(*sorted(a, reverse=s > 0))


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans
mod = int(1000000000.0) + 7

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

def iinp():
	return int(input())

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
for _ in range(iinp()):
	n = iinp()
	a = llinp()
	if sum(a) == 0:
		print('NO')
	else:
		f = 0
		print('YES')
		a.sort()
		s = 0
		for i in a:
			s = s + i
			if s == 0:
				f = 1
				break
		if f == 1:
			a.reverse()
			print(*a)
		else:
			print(*a)


import sys
import heapq
import copy
import math
import decimal
input = sys.stdin.readline

def binary_exponentiation(a, b):
	ans = 1
	while b != 0:
		bit = b % 2
		if bit == 1:
			ans = ans * a
		a = a * a
		b = b // 2
	return ans

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	s = list(s[:len(s) - 1])
	s = [ord(s[i]) - ord('a') for i in range(len(s))]
	return s

def invr():
	return map(int, input().split())
ans = 0

def pr_list(a):
	print(*a, sep=' ')

def swap(a, b):
	temp = a
	a = b
	b = temp
	return [a, b]

def pri(a, b):
	s = '? ' + str(a) + ' ' + str(b)
	print(s)
	sys.stdout.flush()
result = []

def nCk(arr, itr, k, n):
	if len(arr) == k:
		result.append(arr)
		return
	if len(arr) > k or itr == n + 1:
		return
	nCk(arr + [itr], itr + 1, k, n)
	nCk(arr, itr + 1, k, n)
	return

def nPk(arr, itr, k, n):
	if len(arr) == k:
		result.append(arr)
		return
	if len(arr) > k or itr == n + 1:
		return
	for i in range(len(arr) + 1):
		nPk(arr[0:i] + [itr] + arr[i:len(arr)], itr + 1, k, n)
	nPk(arr, itr + 1, k, n)
	return

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		n = inp()
		a = inlt()
		hashm = {}
		pos = []
		neg = []
		zero = []
		for i in a:
			if i > 0:
				pos.append(i)
			elif i < 0:
				neg.append(i)
			else:
				zero.append(i)
		b = pos + neg + zero
		pre = 0
		flag = 0
		for i in b:
			pre = pre + i
			if pre == 0:
				flag = 1
				break
		if flag == 0:
			print('YES')
			pr_list(b)
		else:
			b = neg + pos + zero
			pre = 0
			flag = 0
			for i in b:
				pre = pre + i
				if pre == 0:
					flag = 1
					break
			if flag == 0:
				print('YES')
				pr_list(b)
			else:
				print('NO')
main()


x = int(input())
for _ in range(x):
	l = int(input())
	diz = list(map(int, input().split()))
	diz.sort()
	tot = sum(diz)
	yes = 0
	if tot > 0:
		diz = diz[::-1]
		yes = 1
	elif tot < 0:
		yes = 1
	if yes == 1:
		print('YES')
		print(' '.join(map(str, diz)))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	if sum(ls) == 0:
		print('NO')
	elif sum(ls) < 0:
		print('YES')
		print(*sorted(ls))
	else:
		print('YES')
		print(*sorted(ls, reverse=True))


for _ in range(int(input())):
	_ = input()
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	if s == 0:
		print('NO')
		continue
	if s > 0:
		a.reverse()
	print('YES\n', *a)


for i in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort(reverse=True)
	sumv = sum(l)
	if sumv == 0:
		print('NO')
	else:
		sumv = l[0]
		if sumv == 0:
			temp = l[0]
			l[0] = l[1]
			l[1] = temp
			sumv = l[0]
		for i in range(1, n):
			sumv += l[i]
			if sumv == 0:
				temp = l[i]
				l[i] = l[i - 1]
				l[i - 1] = temp
				sumv = l[i]
		sumv = l[0]
		count = 0
		for i in range(1, n):
			sumv += l[i]
			if sumv == 0:
				count += 1
		l2 = l.copy()
		l2.sort()
		count2 = 0
		sumv2 = l2[0]
		for i in range(1, n):
			sumv += l[i]
			if sumv2 == 0:
				count2 += 1
		if count == 0:
			print('YES')
			print(*l)
		elif count2 == 0:
			print('YES')
			print(*l2)
		else:
			print('NO')


def ans(a, n):
	x = sum(a)
	if x == 0:
		print('NO')
		return
	else:
		print('YES')
		if x > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		for i in a:
			print(i, end=' ')
		print('')
		return
m = int(input())
for j in range(m):
	n = int(input())
	y = input().split()
	a = []
	for i in y:
		a.append(int(i))
	ans(a, n)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	summ = sum(arr)
	if summ == 0:
		print('NO')
	elif summ > 0:
		print('YES')
		arr.sort(reverse=True)
		print(*arr)
	else:
		print('YES')
		arr.sort()
		print(*arr)


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	n = int(input())
	l = list(put())
	l.sort()
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l = l[-1::-1]
		print(' '.join((str(x) for x in l)))
	else:
		print('YES')
		print(' '.join((str(x) for x in l)))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		a.sort(reverse=True)
		print(*a)
	else:
		print('YES')
		a.sort()
		print(*a)


for _ in range(int(input())):
	input()
	a = sorted(map(int, input().split()))
	sa = sum(a)
	if sa:
		print('YES')
		if sa > 0:
			a.reverse()
		print(*a)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	summ = sum(a)
	if not summ:
		print('NO')
	else:
		print('YES')
		if summ > 0:
			for i in range(n - 1, -1, -1):
				print(a[i], end=' ')
		else:
			for i in range(n):
				print(a[i], end=' ')
		print()


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(o) for o in input().split()]
		a.sort()
		a = a[::-1]
		su = sum(a)
		if su == 0:
			print('NO')
		elif su > 0:
			print('YES')
			print(*a)
		else:
			a = a[::-1]
			print('YES')
			print(*a)
sync_with_stdio(False)
main()


for _ in range(int(input())):
	n = int(input())
	k = [int(j) for j in input().split()]
	s = sum(k)
	if s > 0:
		print('YES\n', *sorted(k, reverse=True))
	elif s < 0:
		print('YES\n', *sorted(k, reverse=False))
	else:
		print('NO')


import random
for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
		continue
	for i in range(1000):
		broken = 0
		random.shuffle(arr)
		suma = 0
		for j in range(n):
			ele = arr[j]
			if suma + ele == 0:
				broken += 1
				break
			else:
				suma += ele
		if broken == 0:
			break
	print('YES')
	print(*arr)


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	pos = 0
	neg = 0
	for num in b:
		if num > 0:
			pos += num
		else:
			neg += num
	list1 = []
	if sum(b) == 0:
		print('NO')
	else:
		print('YES')
		if pos > abs(neg):
			b.sort()
			list1 = []
			for i in reversed(b):
				list1.append(i)
			print(*list1)
		elif abs(neg) > pos:
			print(*sorted(b))
		elif abs(neg) == pos:
			print(*b)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	a = list(I())
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		(pos, neg) = (0, 0)
		for x in a:
			if x > 0:
				pos += x
			else:
				neg += x
		if abs(pos) < abs(neg):
			a.sort()
			print(*a)
		else:
			a.sort(reverse=True)
			print(*a)


def avoid(values):
	if sum(values) == 0:
		print('NO')
	elif sum(values) > 0:
		print('YES')
		values.sort(reverse=True)
		print(*values)
	elif sum(values) < 0:
		print('YES')
		values.sort()
		print(*values)
t = int(input())
for i in range(t):
	n = int(input())
	values = list(map(int, input().split()))
	avoid(values)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	positive = []
	negative = []
	zero = []
	for x in a:
		if x > 0:
			positive.append(x)
		elif x < 0:
			negative.append(x)
		else:
			zero.append(x)
	if sum(positive) < -sum(negative):
		print('YES')
		print(*negative + positive + zero)
	elif sum(positive) > -sum(negative):
		print('YES')
		print(*positive + negative + zero)
	else:
		print('NO')


import math
T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	d = False
	if sum(a) > 0:
		a.sort(reverse=True)
	elif sum(a) < 0:
		a.sort()
	else:
		print('NO')
		d = True
		continue
	z = a.count(0)
	if a[0] != 0:
		z = 0
	print('YES')
	for i in range(n):
		print(a[(z + i) % n], end=' ')
	print()


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.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(io.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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	N = int(input())
	A = sorted(map(int, input().split()))
	sumA = sum(A)
	sum_pos = sum((a for a in A if a > 0))
	sum_neg = sumA - sum_pos
	if sumA == 0:
		print('NO')
		continue
	print('YES')
	if sum_pos > -sum_neg:
		print(*A[::-1])
	else:
		print(*A)


t = int(input())
for tests in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if sum(a) == 0:
		print('NO')
		continue
	elif sum(a) > 0:
		sequence = sorted(a)[::-1]
	else:
		sequence = sorted(a)
	print('YES')
	print(' '.join(map(str, sequence)))


(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 = 1
num = int(z())
for _ in range(num):
	n = int(z())
	arr = zzz()
	ans1 = []
	ans2 = []
	po = 0
	ne = 0
	d = 0
	for i in arr:
		if i > 0:
			po += i
			ans1.append(i)
		if i < 0:
			ne += i
			ans2.append(i)
		if i == 0:
			d += 1
	if po + ne == 0:
		print('NO')
		continue
	print('YES')
	if po + ne > 0:
		print(*ans1 + ans2 + [0] * d)
	else:
		print(*ans2 + ans1 + [0] * d)


from sys import stdin
_input = stdin.readline
(_int, _sum, _range) = (int, sum, range)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		arr = [_int(i) for i in _input().split()]
		if _sum(arr) == 0:
			print('NO')
		else:
			counter = 0
			ans_p = []
			ans_o = []
			for i in arr:
				if i == 0:
					counter += 1
				elif i > 0:
					ans_p.append(i)
				else:
					ans_o.append(i)
			print('YES')
			if _sum(ans_p) < -_sum(ans_o):
				print(*ans_o, *[0] * counter, *ans_p, sep=' ')
			else:
				print(*ans_p, *[0] * counter, *ans_o, sep=' ')
solution()


t = int(input())
for _ in range(t):
	n = int(input())
	A = [int(i) for i in input().split()]
	sumA = sum(A)
	B = []
	ans = []
	if sumA > 0:
		for a in A:
			if a > 0:
				ans.append(str(a))
			else:
				B.append(str(a))
		for a in B:
			ans.append(a)
	elif sumA < 0:
		for a in A:
			if a < 0:
				ans.append(str(a))
			else:
				B.append(str(a))
		for a in B:
			ans.append(a)
	if ans != []:
		print('YES')
		print(' '.join(ans))
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split()])
	pos = 0
	neg = 0
	p = []
	n = []
	z = []
	for i in l:
		if i == 0:
			z.append(0)
		elif i > 0:
			pos = pos + i
			p.append(i)
		else:
			neg = neg + i
			n.append(i)
	if pos == abs(neg):
		print('NO')
	elif pos > abs(neg):
		print('YES')
		print(*p + n + z)
	else:
		print('YES')
		print(*n + p + z)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		s = 0
		flag1 = 0
		a.sort(reverse=True)
		for i in range(n):
			s += a[i]
			if s == 0:
				flag1 = 1
		if flag1 == 0:
			print('YES')
			print(' '.join(list(map(str, a))))
			continue
		s = 0
		a.sort()
		flag2 = 0
		for i in range(n):
			s += a[i]
			if s == 0:
				flag2 = 1
		if flag2 == 0:
			print('YES')
			print(' '.join(list(map(str, a))))
			continue
		print('NO')


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	t = 0
	p = 0
	for i in num:
		if i > 0:
			p += i
		elif i < 0:
			t += i
	if t + p == 0:
		print('NO')
	else:
		print('YES')
		num.sort()
		if p > abs(t):
			num = reversed(num)
		for i in num:
			print(i, end=' ')
		print()


import random

def check(l):
	s = 0
	for i in l:
		s += i
		if s == 0:
			return False
	return True

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
		return
	while not check(l):
		random.shuffle(l)
	print('YES')
	print(*l)
t = int(input())
while t:
	solve()
	t -= 1


for q in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())), reverse=True)
	if sum(a) == 0:
		print('NO')
	else:
		z = 0
		b = []
		for i in range(n):
			if a[i] == 0:
				z += 1
			else:
				b.append(a[i])
		r = 0
		for i in range(len(b)):
			r += b[i]
			if r == 0:
				break
		print('YES')
		if r == 0:
			print(*b[::-1] + [0] * z)
		else:
			print(*b + [0] * z)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	lc = sorted([(-abs(x), x) for x in l])
	(lp, lm) = ([], [])
	for (_, x) in lc:
		if x >= 0:
			lp.append(x)
		else:
			lm.append(x)
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(lp) + sum(lm) < 0:
			(lp, lm) = (lm, lp)
		for x in (lp + lm)[:-1]:
			print(x, end=' ')
		print((lp + lm)[-1])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	(sumPos, sumNeg) = (0, 0)
	for i in arr:
		if i >= 0:
			sumPos += i
		else:
			sumNeg += i
	if abs(sumPos) > abs(sumNeg):
		print('YES')
		arr = sorted(arr, reverse=True)
		for i in arr:
			print('{} '.format(i), end='')
		print()
	elif abs(sumPos) < abs(sumNeg):
		print('YES')
		arr = sorted(arr)
		for i in arr:
			print('{} '.format(i), end='')
		print()
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	suma = sum(arr)
	if suma == 0:
		print('NO')
	elif suma > 0:
		print('YES')
		arr.sort(reverse=True)
		print(*arr)
	elif suma < 0:
		print('YES')
		arr.sort()
		print(*arr)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		suma1 = 0
		suma2 = 0
		for i in range(n):
			if a[i] > 0:
				suma1 += a[i]
			else:
				suma2 += a[i]
		if suma1 > abs(suma2):
			a.sort(reverse=True)
		else:
			a.sort()
		print(*a)


def solve(arr, n):
	temp = sum(arr)
	if temp == 0:
		return ['NO']
	(pos, neg, zer) = ('', '', '')
	for i in arr:
		if i > 0:
			pos += str(i) + ' '
		elif i < 0:
			neg += str(i) + ' '
		else:
			zer += '0' + ' '
	if temp > 0:
		return ['YES', pos + neg + zer[:-1]]
	else:
		return ['YES', neg + pos + zer[:-1]]
t = int(input())
results = []
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	results.append(solve(arr, n))
for i in results:
	if len(i) == 1:
		print(i[0])
	else:
		print(i[0])
		print(i[1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	positive = 0
	negative = 0
	a_pos = []
	a_neg = []
	for elem in a:
		if elem > 0:
			positive += elem
			a_pos.append(elem)
		elif elem < 0:
			negative += elem
			a_neg.append(elem)
	if positive == -negative:
		print('NO')
		continue
	elif positive > -negative:
		print('YES')
		print(*a_pos + [0] * (n - len(a_pos) - len(a_neg)) + a_neg)
	else:
		print('YES')
		print(*a_neg + [0] * (n - len(a_pos) - len(a_neg)) + a_pos)


ans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	if sum(u) == 0:
		ans.append('NO')
		continue
	u.sort()
	if sum(u) > 0:
		u.reverse()
	ans.append('YES')
	ans.append(' '.join(map(str, u)))
print('\n'.join(ans))


import math
t = int(input())
while t > 0:
	n = int(input())
	s = list(map(int, input().split()))
	if sum(s) == 0:
		print('NO')
	else:
		print('YES')
		s.sort()
		sumz = 0
		sumf = 0
		for i in s:
			if i > 0:
				sumz = sumz + i
			else:
				sumf = sumf + i
		if abs(sumf) < sumz:
			s.reverse()
		print(' '.join(map(str, s)))
	t = t - 1


def main(arr):
	x = sum(arr)
	if x == 0:
		print('NO')
		return
	print('YES')
	if x > 0:
		arr.sort(reverse=True)
		print(*arr)
		return
	arr.sort()
	print(*arr)
	return
n = int(input())
for i in range(n):
	input()
	x = list(map(int, input().split(' ')))
	main(x)


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	neg = []
	pos = []
	for i in range(n):
		if arr[i] < 0:
			neg.append(arr[i])
		else:
			pos.append(arr[i])
	pos.sort(reverse=True)
	neg.sort()
	total = sum(arr)
	if total == 0:
		print('NO')
	else:
		print('YES')
		if total > 0:
			res = pos + neg
		else:
			res = neg + pos
		print(*res)
	T -= 1


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	total = sum(a)
	if total == 0:
		print('NO')
	elif total > 0:
		b = sorted(a, reverse=True)
		print('YES')
		print(' '.join(map(str, b)))
	else:
		b = sorted(a)
		print('YES')
		print(' '.join(map(str, b)))
t = int(input())
for _ in range(t):
	solve()


for t in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split(' ')])
	suma = sum(a)
	if suma == 0:
		print('NO')
		continue
	print('YES')
	suma = 0
	for i in range(n):
		if suma + a[i] == 0:
			a = a[:i] + a[i:][::-1]
			break
		suma += a[i]
	suma = 0
	for i in range(n):
		if suma + a[i] == 0:
			a = a[::-1]
			break
		suma += a[i]
	print(*a)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

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 inputstrings():
	return [x for x in input().split()]

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
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	sm = 0
	for i in range(n):
		sm += a[i]
	if sm < 0:
		a.sort()
	else:
		a.sort(reverse=True)
	cur = 0
	done = False
	for i in range(n):
		cur += a[i]
		if cur == 0:
			done = True
			break
	if done:
		print('NO')
	else:
		print('YES')
		print(*a)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		arr.sort()
		check = True
		temp = 0
		for i in range(n):
			temp += arr[i]
			if temp == 0:
				check = False
				break
		if check:
			print('YES')
			print(*arr)
		else:
			arr.sort(reverse=True)
			temp = 0
			check = True
			for i in range(n):
				temp += arr[i]
				if temp == 0:
					check = False
					break
			if check:
				print('YES')
				print(*arr)
			else:
				print('NO')
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if sum(a) < 0:
			a.sort()
			a = list(map(str, a))
			print(' '.join(a))
		else:
			a.sort(reverse=True)
			a = list(map(str, a))
			print(' '.join(a))


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	z = sum(li)
	if z == 0:
		print('NO')
	elif z < 0:
		print('YES')
		l1 = []
		l2 = []
		for i in li:
			if i < 0:
				l1.append(i)
			else:
				l2.append(i)
		for i in l1:
			print(i, end=' ')
		for i in l2:
			print(i, end=' ')
		print()
	else:
		print('YES')
		l1 = []
		l2 = []
		for i in li:
			if i > 0:
				l1.append(i)
			else:
				l2.append(i)
		for i in l1:
			print(i, end=' ')
		for i in l2:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	for i in range(n):
		s = s + a[i]
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		for i in range(n):
			print(a[i], end=' ')
		print()


import io
import os
import sys
import math
input = sys.stdin.readline
mod = 10 ** 9 + 7
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		pos = []
		neg = []
		for el in arr:
			if el < 0:
				neg.append(abs(el))
			else:
				pos.append(el)
		pos.sort(reverse=True)
		if sum(neg) > sum(pos):
			x = []
			for el in neg:
				x.append(-el)
			for el in pos:
				x.append(el)
			print('YES')
			print(*x)
		else:
			x = []
			for el in pos:
				x.append(el)
			for el in neg:
				x.append(-el)
			print('YES')
			print(*x)


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = sum(a)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		print(*reversed(sorted(a)))
	else:
		print('YES')
		print(*sorted(a))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	summ = sum(a)
	if summ == 0:
		print('NO')
	else:
		(sum_n, sum_p) = (0, 0)
		for i in range(n):
			if a[i] < 0:
				sum_n += a[i]
		for i in range(n):
			if a[i] > 0:
				sum_p += a[i]
		if abs(sum_n) > sum_p:
			a.sort()
		else:
			a.sort(reverse=True)
		print('YES')
		print(*a)
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	A = list(map(int, input().split(' ')))
	nA = []
	pA = []
	B = []
	for i in range(n):
		if A[i] < 0:
			nA.append(A[i])
		else:
			pA.append(A[i])
	if abs(sum(nA)) == abs(sum(pA)):
		print('NO')
	elif abs(sum(pA)) > abs(sum(nA)):
		pA = sorted(pA, reverse=True)
		B = pA + nA
		print('YES')
		print(*B)
	else:
		B = nA + pA
		print('YES')
		print(*B)


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')
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	neg = 0
	pos = 0
	for s in range(n):
		if vals[s] >= 0:
			pos += vals[s]
		else:
			neg += abs(vals[s])
	if neg <= pos:
		vals.sort(reverse=True)
	else:
		vals.sort()
	prefsum = 0
	broke = False
	for s in range(n):
		prefsum += vals[s]
		if prefsum == 0:
			broke = True
			break
	if broke == False:
		print('YES')
		print(*vals)
	else:
		print('NO')


import math
t = int(input())
for q in range(t):
	n = int(input())
	L = [int(i) for i in input().split()]
	mi = []
	ma = []
	s = 0
	for i in L:
		s += i
		if i < 0:
			mi.append(i)
		else:
			ma.append(i)
	mi.sort()
	ma.sort(reverse=True)
	if s > 0:
		print('YES')
		for i in ma:
			print(i, end=' ')
		for i in mi:
			print(i, end=' ')
		print('')
	elif s < 0:
		print('YES')
		for i in mi:
			print(i, end=' ')
		for i in ma:
			print(i, end=' ')
		print('')
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		ps = []
		ns = []
		zeros = []
		for v in a:
			if v > 0:
				ps += [v]
			elif v < 0:
				ns += [v]
			else:
				zeros += [v]
		if abs(sum(ps)) > abs(sum(ns)):
			ans = ps + ns + zeros
			print(*ans)
		else:
			ans = ns + ps + zeros
			print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	less = []
	more = []
	nulls = 0
	for i in range(n):
		if arr[i] > 0:
			more.append(arr[i])
		elif arr[i] < 0:
			less.append(arr[i])
		else:
			nulls += 1
	out = []
	if sum(more) > abs(sum(less)):
		out += more
		out += less
	else:
		out += less
		out += more
	out += [0] * nulls
	flag = True
	s = 0
	for i in range(n):
		s += out[i]
		if s == 0:
			flag = False
	if flag:
		print('YES')
		print(*out)
	else:
		print('NO')


for case in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	suma = sum(arr)
	lista = []
	solved = False
	if all((arr[i] == 0 for i in range(N))):
		print('NO')
	else:
		while len(arr) > 0:
			found = False
			for i in range(len(arr)):
				if arr[i] == 0:
					lista = ['0'] + lista
					arr.pop(i)
					found = True
					break
				elif sum(arr) - arr[i] != -arr[i] and suma - arr[i] != 0 or len(arr) == 1:
					lista.append(str(arr[i]))
					suma -= arr[i]
					arr.pop(i)
					found = True
					break
			if found == False:
				print('NO')
				solved = True
				break
		if solved == False:
			print('YES')
			print(' '.join(lista[::-1]))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
		return
	print('YES')
	if s > 0:
		a.sort(reverse=True)
	else:
		a.sort()
	print(*a)
t = int(input())
for _ in range(t):
	solve()


T = int(input())
for t in range(T):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	pos = [x for x in arr if x > 0]
	neg = [x for x in arr if x < 0]
	zero = [x for x in arr if x == 0]
	pos_sum = sum(pos)
	neg_sum = -1 * sum(neg)
	if pos_sum - neg_sum == 0:
		print('NO')
		continue
	if pos_sum > neg_sum:
		arr = pos
		arr.extend(neg)
	else:
		arr = neg
		arr.extend(pos)
	arr.extend(zero)
	summer = 0
	valid = True
	for each in arr:
		summer += each
		if summer == 0:
			valid = False
			break
	if valid:
		print('YES')
		print(*arr)
	else:
		print('NO')


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve():
	li = [True] * (10 ** 3 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	(prime, cur) = ([0] * 200, 0)
	for i in range(10 ** 3 + 5):
		if li[i] == True:
			prime[cur] = i
			cur += 1
	return prime

def SPF():
	mx = 10 ** 6 + 1
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == 1000000000.0:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return

def prime(n, d):
	prm = set()
	while n != 1:
		prm.add(spf[n])
		n = n // spf[n]
	for ele in prm:
		d[ele] = d.get(ele, 0) + 1
	return
mod = 998244353

def solve():
	n = II()
	a = L()
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		(pos, neg) = ([], [])
		zero = []
		for ele in a:
			if ele > 0:
				pos.append(ele)
			elif ele < 0:
				neg.append(ele)
			else:
				zero.append(0)
		pos.sort()
		neg.sort(reverse=True)
		if sum(pos) > abs(sum(neg)):
			for ele in neg:
				pos.append(ele)
			for ele in zero:
				pos.append(0)
			print(*pos)
		else:
			for ele in pos:
				neg.append(ele)
			for ele in zero:
				neg.append(0)
			print(*neg)
	return
t = II()
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	p = sum(arr)
	if p == 0:
		print('NO')
	else:
		if p < 0:
			arr.sort()
		else:
			arr.sort(reverse=True)
		print('YES')
		print(' '.join((str(x) for x in arr)))


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	if sum(list1) == 0:
		print('NO')
	elif sum(list1) > 0:
		print('YES')
		list1.sort(reverse=True)
		print(*list1)
	else:
		print('YES')
		list1.sort()
		print(*list1)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	if sum(a) > 0:
		a.sort(reverse=True)
		print(*a)
	else:
		a.sort()
		print(*a)


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	if sum(array) == 0:
		print('NO')
	else:
		print('YES')
		if sum(array) < 0:
			print(*sorted(array))
		else:
			print(*sorted(array, reverse=True))


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	smneg = 0
	negarr = []
	posarr = []
	smpos = 0
	for j in range(0, n):
		if a[j] < 0:
			smneg += a[j]
			negarr.append(a[j])
		else:
			smpos += a[j]
			posarr.append(a[j])
	if abs(smneg) != smpos:
		print('YES')
		posarr.sort(reverse=True)
		negarr.sort()
		if smpos > abs(smneg):
			print(' '.join([str(x) for x in posarr + negarr]))
		else:
			print(' '.join([str(x) for x in negarr + posarr]))
	else:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	mylist = list(map(int, input().split()))
	suma = sumb = 0
	mylist.sort()
	for i in range(0, x):
		if mylist[i] < 0:
			sumb += mylist[i]
		else:
			suma += mylist[i]
	if abs(sumb) > suma:
		print('YES')
		print(*mylist)
	elif suma > abs(sumb):
		print('YES')
		mylist = mylist[::-1]
		print(*mylist)
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = sum(arr)
	if x == 0:
		print('NO')
	elif x < 0:
		arr.sort()
		print('YES')
		print(*arr)
	elif x > 0:
		arr.sort(reverse=True)
		print('YES')
		print(*arr)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	p = []
	ps = 0
	ns = 0
	ne = []
	zero = []
	for i in l:
		if i > 0:
			p += [i]
			ps += i
		elif i < 0:
			ne += [i]
			ns += i
		else:
			zero += [i]
	if ps + ns == 0:
		indi = 0
	elif ps + ns > 0:
		s = p + ne + zero
		indi = 1
	else:
		s = ne + p + zero
		indi = 1
	if indi == 1:
		print('YES')
		st = str(s[0])
		for k in s[1:]:
			st += ' ' + str(k)
		print(st)
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	alist = [int(x) for x in input().split()]
	asum = sum(alist)
	if asum == 0:
		print('NO')
	elif asum > 0:
		print('YES')
		print(*sorted(alist, reverse=True), sep=' ')
	else:
		print('YES')
		print(*sorted(alist), sep=' ')


for t in range(int(input())):
	n = int(input().lstrip())
	arr = list(map(int, input().lstrip().split()))
	sm = sum(arr)
	if sm == 0:
		print('NO')
	else:
		if sm < 0:
			ans = sorted(arr)
		else:
			ans = sorted(arr, reverse=True)
		print('YES')
		for i in ans[:-1]:
			print(i, end=' ')
		print(ans[-1])


def main():
	n = int(input())
	lst = sorted(list(map(int, input().split())), reverse=True)
	sm = 0
	can_be = True
	for i in lst:
		sm += i
		if sm == 0:
			can_be = False
	if can_be:
		print('YES')
		for i in lst:
			print(i, end=' ')
		print()
		return
	else:
		lst = list(reversed(lst))
		sm = 0
		can_be = True
		for i in lst:
			sm += i
			if sm == 0:
				can_be = False
		if can_be:
			print('YES')
			for i in lst:
				print(i, end=' ')
			print()
			return
		else:
			print('NO')
t = int(input())
for i in range(t):
	main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	z = 0
	(ps, ns) = (0, 0)
	for i in l:
		if i > 0:
			pos.append(i)
			ps += i
		elif i == 0:
			z += 1
		else:
			neg.append(i)
			ns += abs(i)
	if ps > ns:
		print('YES')
		temp = pos + neg + [0] * z
		print(*temp)
	elif ps == ns:
		print('NO')
	else:
		print('YES')
		temp = neg + pos + [0] * z
		print(*temp)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	result = []
	pos = []
	neg = []
	zeros = []
	for i in arr:
		if i == 0:
			zeros.append(i)
		elif i > 0:
			pos.append(i)
		else:
			neg.append(i)
	pos_sum = abs(sum(pos))
	neg_sum = abs(sum(neg))
	if pos_sum > neg_sum:
		result = [*pos, *zeros, *neg]
	elif neg_sum > pos_sum:
		result = [*neg, *zeros, *pos]
	else:
		print('NO')
		continue
	print('YES')
	for i in result:
		print(i, end=' ')
	print('')


for i in range(int(input())):
	size = int(input())
	nums = list(map(int, input().split(' ')))
	if sum(nums) == 0:
		print('NO')
	elif sum(nums) > 0:
		print('YES')
		print(*reversed(sorted(nums)))
	else:
		print('YES')
		print(*sorted(nums))


for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	pi = []
	ni = []
	zi = []
	bi = []
	for ele in ai:
		if ele > 0:
			pi.append(ele)
		elif ele < 0:
			ni.append(ele)
		else:
			zi.append(ele)
	if sum(pi) > abs(sum(ni)):
		bi = pi + zi + ni
		print('YES')
		print(*bi)
	elif sum(pi) < abs(sum(ni)):
		bi = ni + zi + pi
		print('YES')
		print(*bi)
	else:
		print('NO')


t = int(input())
for zzz in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	if sum(data) == 0:
		print('NO')
		continue
	else:
		data = sorted(data)
		if sum(data) < 0:
			print('YES')
			print(' '.join(map(str, data)))
		else:
			print('YES')
			print(' '.join(map(str, reversed(data))))


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

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
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	x = 0
	y = 0
	xx = []
	yy = []
	for i in range(n):
		if a[i] >= 0:
			x += a[i]
			xx.append(a[i])
		else:
			y += a[i]
			yy.append(a[i])
	xx.sort(reverse=True)
	if x > abs(y):
		print('YES')
		print(*xx, end=' ')
		print(*yy)
	elif abs(y) > x:
		print('YES')
		print(*yy, end=' ')
		print(*xx)
	else:
		print('NO')


import array
T = int(input())
for Tid in range(T):
	n = int(input())
	a = array.array('i', map(int, input().split()))
	s = 0
	a = sorted(a)
	for i in range(n):
		s += a[i]
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s < 0:
			for i in range(n):
				print(a[i], end=' ')
		else:
			for i in range(n - 1, -1, -1):
				print(a[i], end=' ')
		print()


game = int(input())
for i in range(game):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		print(*reversed(sorted(a)))
	else:
		print('YES')
		print(*sorted(a))


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	s = sum(A)
	if s == 0:
		print('NO')
		continue
	if s < 0:
		A.sort()
	else:
		A.sort(reverse=True)
	print('YES')
	for a in A:
		print(a, end=' ')
	print()


num_cases = int(input())
for case in range(num_cases):
	num_ints = int(input())
	ints = list(map(int, input().split()))
	sm = sum(ints)
	if sm == 0:
		print('NO')
	else:
		ints = sorted(ints)
		if sm > 0:
			ints = ints[::-1]
		print('YES')
		print(*ints)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	s = sum(ar)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s < 0:
			print(*ar)
		else:
			print(*ar[::-1])


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if sum(a) > 0:
		print('YES')
		print(*a[::-1])
	elif sum(a) < 0:
		print('YES')
		print(*a)
	else:
		print('NO')


def solve(n, arr):
	arr1 = []
	summ = 0
	sum1 = 0
	sum2 = 0
	check = True
	for i in range(n):
		if arr[i] >= 0:
			sum1 += arr[i]
		else:
			sum2 += arr[i]
	if sum1 == -sum2:
		print('NO')
	else:
		print('YES')
		arr.sort()
		arr1 = arr[::-1]
		for i in range(n):
			summ = summ + arr[i]
			if summ == 0:
				return arr1
		return arr
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = solve(n, arr)
	if ans != None:
		for i in ans:
			print(i, end=' ')
		print('')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	s = a[0]
	i = 0
	if sum(a) == 0:
		print('No')
	else:
		print('Yes')
		for j in a:
			if j < 0:
				i += 1
			else:
				break
		if -sum(a[:i]) < sum(a[i:]):
			print(*list(reversed(a)))
		else:
			print(*a)


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	tot = 0
	L1 = []
	L2 = []
	L3 = []
	cp = 0
	cn = 0
	for i in range(0, len(s)):
		tot += s[i]
		if s[i] > 0:
			L1.append(s[i])
			cp += s[i]
		elif s[i] == 0:
			L2.append(s[i])
		else:
			L3.append(s[i])
			cn += abs(s[i])
	if tot == 0:
		print('NO')
	elif cp > cn:
		ans = L1 + L3 + L2
		print('YES')
		print(*ans)
	else:
		ans = L3 + L1 + L2
		print('YES')
		print(*ans)


from sys import stdin
from math import gcd
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	if sum(a) > 0:
		print('YES')
		print(*a[::-1])
	elif sum(a) < 0:
		print('YES')
		print(*a)
	else:
		print('NO')


q = int(input())
for _ in range(q):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	c = sum(b)
	if c == 0:
		print('NO')
	elif c < 0:
		print('YES')
		print(*b)
	elif c > 0:
		b.reverse()
		print('YES')
		print(*b)


import sys
import math
from decimal import *

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

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

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		n = []
		p = []
		res = []
		for ll in l:
			if ll < 0:
				n.append(ll)
			else:
				p.append(ll)
		n.sort()
		p.sort(reverse=True)
		np = abs(sum(n))
		pp = abs(sum(p))
		if np == pp:
			print('NO')
			continue
		elif pp > np:
			res.extend(p)
			res.extend(n)
		else:
			res.extend(n)
			res.extend(p)
		print('YES')
		for ll in res:
			print(ll, end=' ')
		print()
		pass
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	sl = sum(li)
	if sl == 0:
		print('NO')
		continue
	if sl > 0:
		li.sort(reverse=True)
	else:
		li.sort(reverse=False)
	noo = False
	for i in li:
		if i != 0:
			ans = [i]
			s = i
			break
	li.remove(ans[-1])
	while len(ans) != n:
		f = True
		for i in li:
			if i + s != 0:
				ans.append(i)
				f = False
				break
		if f:
			noo = True
			break
		s += ans[-1]
		li.remove(ans[-1])
	if noo:
		print('NO')
	else:
		print('YES')
		print(*ans)


def func():
	t = int(input())
	for _ in range(t):
		_ = int(input())
		lst = list(map(int, input().strip().split()))
		if sum(lst) == 0:
			print('NO')
		else:
			print('YES')
			if sum(lst) > 0:
				lst = sorted(lst, reverse=True)
			elif sum(lst) < 0:
				lst = sorted(lst)
			print(' '.join(map(str, lst)))
func()


t = int(input())
for i in range(t):
	n = int(input())
	aarr = list(map(int, input().split()))
	aarr.sort()
	summation = sum(aarr)
	flag = False
	if summation == 0:
		print('NO')
		flag = True
	elif summation > 0:
		aarr.sort(reverse=True)
	if not flag:
		print('YES')
		print(*aarr)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	l.sort()
	l_final = []
	check = True
	for each in l:
		l_final.append(each)
		if sum(l_final) == 0:
			check = False
			break
	l_final = []
	if check:
		print('YES')
		print(' '.join(map(str, l)))
		continue
	else:
		check = True
		l.sort(reverse=True)
		for each in l:
			l_final.append(each)
			if sum(l_final) == 0:
				check = False
				break
	if check:
		print('YES')
		print(' '.join(map(str, l)))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a = sorted(a)
		if sum(a) > 0:
			a = reversed(a)
		for i in a:
			print(i, end=' ')
		print()


testCase = int(input())
for tc in range(testCase):
	n = int(input())
	arr = list(map(int, input().split()))
	neg = [i for i in arr if i <= 0]
	pos = [i for i in arr if i > 0]
	neg.sort()
	(sumneg, sumpos) = (sum(neg), sum(pos))
	if sumneg + sumpos < 0:
		print('YES')
		print(' '.join([str(i) for i in neg + pos]))
	elif sumneg + sumpos > 0:
		print('YES')
		print(' '.join([str(i) for i in pos + neg]))
	else:
		print('NO')


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


for _ in ' ' * int(input()):
	a = int(input())
	z = list(map(int, input().split()))
	if sum(z) == 0:
		print('NO')
	elif sum(z) > 0:
		print('YES')
		print(*sorted(z, reverse=True))
	else:
		print('YES')
		print(*sorted(z))


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	L = list(map(int, input().split()))
	if sum(L) == 0:
		print('NO')
		return
	total = 0
	flag = 0
	if sum(L) > 0:
		L.sort(reverse=True)
	else:
		L.sort()
	for i in range(n):
		total += L[i]
		if total == 0:
			(L[i], L[-1]) = (L[-1], L[i])
			if L[i] == L[-1]:
				flag = 1
				break
	if flag == 1:
		print('NO')
		return
	print('YES')
	print(*L)
for _ in range(int(input())):
	solve()


T = int(input())
for t in range(T):
	n = int(input())
	st = input().split()
	A = []
	s = 0
	for i in range(n):
		A.append(int(st[i]))
		s += A[i]
	if s == 0:
		print('NO')
		continue
	else:
		print('YES')
		if s > 0:
			A = sorted(A, reverse=True)
		else:
			A = sorted(A)
		if A[0] == 0:
			for i in range(n):
				if A[i] != 0:
					(A[0], A[i]) = (A[i], A[0])
					break
		for i in range(n):
			print(A[i], end=' ')
		print()


import random
t = int(input())
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	s = sum(li)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			li.sort(reverse=True)
		else:
			li.sort()
		li = str(li)[1:-1].replace(',', '')
		print(li)


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
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 RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())

@lru_cache(None)
def fact(x):
	if x < 2:
		return 1
	return fact(x - 1) * x

@lru_cache(None)
def per(i, j):
	return fact(i) // fact(i - j)

@lru_cache(None)
def com(i, j):
	return per(i, j) // fact(j)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 1
	res = 0
	for w in arr:
		res += w
		if res > x:
			res = w
		c += 1
	return c

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = N()
for i in range(t):
	n = N()
	a = RLL()
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print(*a)


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, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		a1 = sorted(a)
		a2 = a1[::-1]
		ans = 'YES'
		s = 0
		for i in range(n):
			s += a1[i]
			if s == 0:
				ans = 'NO'
		if ans == 'NO':
			ans = 'YES'
			s = 0
			for i in range(n):
				s += a2[i]
				if s == 0:
					ans = 'NO'
			print(ans)
			if ans == 'YES':
				print(*a2)
		else:
			print(ans)
			if ans == 'YES':
				print(*a1)
	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 _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		(i, j) = (0, 0)
		a.sort()
		s = 0
		for k in range(n):
			s += a[k]
			if s == 0:
				i = k
				break
			else:
				i = k
		s = 0
		if i == n - 1:
			print(*a)
			continue
		for k in range(n - 1, -1, -1):
			s += a[k]
			if s == 0:
				j = k
				break
			else:
				j = k
		if j == 0:
			a = a[::-1]
			print(*a)
			continue
		for k in range(i + 1, j):
			print(a[k], end=' ')
		for k in range(0, i + 1):
			print(a[k], end=' ')
		for k in range(j, n):
			print(a[k], end=' ')
		print()


testcases = int(input())
while testcases:
	size = int(input())
	array = map(int, input().split())
	neglist = []
	poslist = []
	reslist = []
	for val in array:
		if val < 0:
			neglist.append(val)
		else:
			poslist.append(val)
	psumval = sum(poslist)
	nsumval = sum(neglist)
	if abs(psumval) == abs(nsumval):
		print('NO')
	else:
		print('YES')
		if abs(psumval) > abs(nsumval):
			reslist.extend(reversed(sorted(poslist)))
			for val in neglist:
				if psumval + val != 0:
					reslist.append(val)
					neglist.remove(val)
					psumval += val
				if len(neglist) == 0:
					break
			reslist.extend(neglist)
		else:
			reslist.extend(neglist)
			for val in poslist:
				if nsumval + val != 0:
					reslist.append(val)
					poslist.remove(val)
					nsumval += val
				if len(poslist) == 0:
					break
			reslist.extend(poslist)
		stri = ''
		for val in reslist:
			stri += str(val) + ' '
		print(stri)
	testcases -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		p = []
		neg = []
		for i in a:
			if i >= 0:
				p.append(i)
			else:
				neg.append(i)
		p.sort(reverse=True)
		if sum(p) > abs(sum(neg)):
			p = p + neg
			print(*p)
		else:
			neg = neg + p
			print(*neg)


tt = int(input())
for tc in range(tt):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		a.sort()
		a.reverse()
		print(*a)
	else:
		print('YES')
		a.sort()
		print(*a)


import sys
lines = sys.stdin.readlines()
cur_line = -1

def input():
	global lines, cur_line
	cur_line += 1
	return lines[cur_line][:-1]
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if sum(s) == 0:
		print('NO')
	elif sum(s) > 0:
		print('YES')
		print(*[k for k in s if k > 0], *[k for k in s if k <= 0])
	elif sum(s) < 0:
		print('YES')
		print(*[k for k in s if k < 0], *[k for k in s if k >= 0])


t = int(input())

def q(l):
	s = sum(l)
	if s == 0:
		return 'NO'
	elif s > 0:
		l.sort()
		l1 = l[::-1]
		return 'YES\n' + ' '.join(map(str, l1))
	else:
		l.sort()
		return 'YES\n' + ' '.join(map(str, l))

def h(l):
	print('YES\n', ' '.join(map(str, l)))
	print(' '.join(map(str, l)))
for i in range(t):
	n = int(input())
	j = input().split()
	l = list(map(int, j))
	print(q(l))


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()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.sort(reverse=True)
			l = []
			top = 0
			end = n - 1
			cur = 0
			while top <= end:
				if cur + a[end] > 0:
					cur += a[end]
					l.append(a[end])
					end -= 1
				else:
					cur += a[top]
					l.append(a[top])
					top += 1
		else:
			a.sort()
			l = []
			top = 0
			end = n - 1
			cur = 0
			while top <= end:
				if cur + a[end] < 0:
					cur += a[end]
					l.append(a[end])
					end -= 1
				else:
					cur += a[top]
					l.append(a[top])
					top += 1
		print(*l)


t = int(input())
for x in range(t):
	n = int(input())
	a = input().split(' ')
	a = [int(x) for x in a]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if sum(a) > 0:
			print(*a[::-1])
		elif sum(a) < 0:
			print(*a)


q = int(input())
for _ in range(q):
	n = int(input())
	data = list(map(int, input().split()))
	su = sum(data)
	if su > 0:
		print('YES')
		print(*sorted(data, reverse=True))
	elif su < 0:
		print('YES')
		print(*sorted(data, reverse=False))
	else:
		print('NO')


import copy
t = int(input())
for run in range(0, t):
	n = input()
	a = input().split(' ')
	a = list(map(lambda x: int(x), a))
	a_sum = 0
	for a_elem in a:
		a_sum += a_elem
	if a_sum == 0:
		print('NO')
	else:
		if a_sum > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print('YES')
		for a_elem in a:
			print(f'{a_elem} ', end='')
		print('\n', end='')


t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	a = input().split()
	a_mod = []
	a_mod_string = []
	for i in range(n):
		a_mod.append(int(a[i]))
	if sum(a_mod) == 0:
		answers.append('NO')
	else:
		yes = []
		yes.append('YES')
		positive = []
		negative = []
		for k in range(n):
			if a_mod[k] < 0:
				negative.append(a_mod[k])
			else:
				positive.append(a_mod[k])
		if abs(sum(negative)) > sum(positive):
			a_mod.sort()
		else:
			a_mod.sort(reverse=True)
		for m in range(n):
			a_mod_string.append(str(a_mod[m]))
		yes.append(a_mod_string)
		answers.append(yes)
for j in range(t):
	if answers[j] == 'NO':
		print(answers[j])
	else:
		print(answers[j][0])
		print(' '.join(answers[j][1]))


for _ in range(int(input())):
	input()
	A = list(map(int, input().split()))
	s = sum(A)
	if s == 0:
		print('NO')
		continue
	print('YES')
	print(*sorted(A, reverse=s > 0))


t = int(input())
for i in range(t):
	n = int(input())
	kek = list(map(int, input().split()))
	if sum(kek) == 0:
		print('NO')
	else:
		print('YES')
		if sum(kek) < 0:
			print(*sorted(kek))
		else:
			print(*sorted(kek)[::-1])


t = int(input())
for x in range(t):
	n = int(input())
	a = input().split()
	pos = []
	neg = []
	zeros = []
	for i in range(n):
		a[i] = int(a[i])
	a.sort()
	total = 0
	for nums in a:
		total += nums
		if total == 0:
			break
	if total != 0:
		print('YES')
		print(*a, sep=' ')
	else:
		a.reverse()
		total = 0
		for nums in a:
			total += nums
			if total == 0:
				break
		if total != 0:
			print('YES')
			print(*a, sep=' ')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	(pos, zer, neg) = ([], [], [])
	(posSum, negSum) = (0, 0)
	for num in a:
		if num < 0:
			neg.append(num)
			negSum += num
		elif num > 0:
			pos.append(num)
			posSum += num
		else:
			zer.append(num)
	ans = []
	if posSum > -negSum:
		ans = pos + neg + zer
	elif posSum < -negSum:
		ans = neg + pos + zer
	else:
		ans = []
	if ans:
		print('YES')
		print(*ans)
	else:
		print('NO')


def readis():
	return map(int, input().strip().split())

def printlist(xs):
	print(' '.join(map(str, xs)))
T = int(input())
while T:
	T -= 1
	n = int(input())
	xs = list(readis())
	ns = list(filter(lambda x: x < 0, xs))
	ps = list(filter(lambda x: x > 0, xs))
	s_p = sum(ps)
	s_n = abs(sum(ns))
	if s_p > s_n:
		sol = list(ps) + list(ns) + [0] * (n - len(ps) - len(ns))
	elif s_p < s_n:
		sol = list(ns) + list(ps) + [0] * (n - len(ps) - len(ns))
	else:
		sol = None
	if sol:
		print('YES')
		printlist(sol)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	check1 = True
	check2 = True
	for i in range(n):
		if sum(a[:i + 1]) == 0:
			check1 = False
		if sum(a[::-1]) == 0:
			check2 = False
	if check1 == False and check2 == False:
		print('NO')
	elif check1 == True:
		print('YES')
		print(' '.join((str(x) for x in a)))
	else:
		print('YES')
		print(' '.join((str(x) for x in a[::-1])))


import itertools, operator
t = int(input())
for lo in range(t):
	n = int(input())
	lis = [int(i) for i in input().split()]
	result = 0
	for el in lis:
		result += el
	if result == 0:
		print('NO')
		continue
	lis.sort()
	print('YES')
	if result < 0:
		for i in lis:
			print(i, end=' ')
		print()
	else:
		for i in range(n - 1, -1, -1):
			print(lis[i], end=' ')
		print()


for i in range(int(input())):
	input()
	a = list(map(int, input().strip().split(' ')))
	if sum(a) > 0:
		print('YES')
		a.sort()
		a.reverse()
		a = ' '.join(list(map(str, a)))
		print(a)
	elif sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		a = ' '.join(list(map(str, a)))
		print(a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l.sort(reverse=True)
		for i in l:
			print(i, end=' ')
		print()
	else:
		print('YES')
		l.sort()
		for i in l:
			print(i, end=' ')
		print()


def sol(a):
	fa = sorted(a)
	s = sum(a)
	if s > 0:
		print('YES')
		print(' '.join(map(str, fa[::-1])))
	if s < 0:
		print('YES')
		print(' '.join(map(str, fa)))
	if s == 0:
		print('NO')
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	sol(a)
	t = t - 1


n = int(input())
for i in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	elif sum(a) > 0:
		a.sort(key=lambda x: -x)
	elif sum(a) < 0:
		a.sort()
	print('YES')
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	numlist = list(map(int, input().split()))
	getall = sum(numlist)
	if getall == 0:
		print('NO')
	elif getall < 0:
		print('YES')
		temp = sorted(numlist)
		for i in range(len(temp)):
			if i != len(temp) - 1:
				print(temp[i], end=' ')
			else:
				print(temp[i])
	elif getall > 0:
		print('YES')
		temp = sorted(numlist, reverse=True)
		for i in range(len(temp)):
			if i != len(temp) - 1:
				print(temp[i], end=' ')
			else:
				print(temp[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		b = a.copy()
		if s > 0:
			b.sort(reverse=True)
		else:
			b.sort()
		print('YES')
		print(' '.join([str(x) for x in b]))


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		A = arrinp()
		x = sum(A)
		if x == 0:
			print('NO')
		else:
			(pos, neg, zero) = ([], [], [])
			for i in A:
				if i > 0:
					pos.append(i)
				elif i < 0:
					neg.append(i)
				else:
					zero.append(i)
			if x > 0:
				ans = pos + neg + zero
			elif x < 0:
				ans = neg + pos + zero
			print('YES')
			print(*ans)
main()


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right
from itertools import permutations

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

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 mod():
	return 10 ** 9 + 7
for i in range(INT()):
	n = INT()
	a = LIST()
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		a.sort()
		if s > 0:
			print('YES')
			print(*a[::-1])
		else:
			print('YES')
			print(*a)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split(' ')))
		if sum(a) == 0:
			print('NO')
			continue
		fir = []
		sec = []
		for x in range(n):
			if a[x] <= 0:
				sec.append(a[x])
			else:
				fir.append(a[x])
		chk = 0
		sec.sort()
		fir.sort(reverse=True)
		if sum(a) > 0:
			boss = fir + sec
		else:
			boss = sec + fir
		for x in range(1, n + 1):
			if sum(boss[:x]) == 0:
				chk = 1
				break
		if chk == 1:
			print('NO')
		else:
			print('YES')
			print(*boss)
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')
main()


from collections import deque
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			for i in sorted(a, reverse=True):
				print(i, end=' ')
		else:
			for i in sorted(a):
				print(i, end=' ')
		print()


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	if sum(a) == 0:
		print('NO')
	else:
		if sum(a) > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print('YES')
		print(*a)


for t in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	s = sum(li)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			li.sort()
			li.reverse()
			print(*li)
		else:
			li.sort()
			print(*li)


import sys
input = sys.stdin.readline

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		s = sum(a)
		if sum(a) == 0:
			print('NO')
			continue
		else:
			if sum(a) > 0:
				a.sort(reverse=True)
			else:
				a.sort()
			print('YES')
			print(*a)
prog()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	t1 = []
	t2 = []
	n1 = 0
	t3 = []
	p1 = 0
	for i in a:
		if i == 0:
			t1 += [i]
		elif i > 0:
			t2 += [i]
			p1 += i
		else:
			n1 += i
			t3 += [i]
	if len(t1) == n or p1 == abs(n1):
		print('NO')
	elif len(t2) == n or len(t3) == n:
		print('YES')
		for i in a:
			print(i, end=' ')
		print()
	else:
		b1 = a[:]
		b1.sort(reverse=True)
		a.sort()
		t1 = 0
		flag = 0
		for i in a:
			t1 += i
			if t1 == 0:
				flag = 1
				break
		if flag == 0:
			print('YES')
			for i in a:
				print(i, end=' ')
			print()
		else:
			t1 = 0
			flag = 0
			for i in b1:
				t1 += i
				if t1 == 0:
					flag = 1
					break
			if flag == 0:
				print('YES')
				for i in b1:
					print(i, end=' ')
				print()
			else:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		s = 0
		for i in a:
			if s + i == 0:
				print(*a[::-1])
				s = 'a'
				break
			else:
				s += i
		if s != 'a':
			print(*a)


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	num = 0
	kek = False
	for elem in ar:
		num += elem
		if num == 0:
			kek = True
			break
	if kek:
		ar.sort(reverse=True)
		num = 0
		kek = False
		for elem in ar:
			num += elem
			if num == 0:
				kek = True
				break
		if kek:
			print('NO')
		else:
			print('YES')
			print(*ar)
	else:
		print('YES')
		print(*ar)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		N = int(input())
		A = list(map(int, input().split()))
		sum_ = sum(A)
		if not sum_:
			print('NO')
		elif sum_ < 0:
			print('YES')
			print(*sorted(A))
		else:
			print('YES')
			print(*sorted(A, reverse=1))
main()


import heapq
import collections
from math import log2
import itertools
from functools import lru_cache
from sys import setrecursionlimit as srl
srl(2 * 10 ** 6)
N = 200001

def solve(n, a):
	p = []
	ne = []
	ps = 0
	ns = 0
	s = 0
	z = 0
	for i in range(n):
		s += a[i]
		if a[i] > 0:
			p.append(a[i])
			ps += a[i]
		elif a[i] == 0:
			z += 1
		elif a[i] < 0:
			ne.append(a[i])
			ns += a[i]
	if s == 0:
		return ['NO']
	else:
		print('YES')
		if ps > abs(ns):
			d = p + ne
			return d + [0] * z
		else:
			d = ne + p
			return d + [0] * z
t = int(input())
for i in range(1, t + 1):
	n = int(input())
	a = list(map(int, input().split()))
	print(*solve(n, a))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l = []
	l2 = []
	c = 0
	for i in range(n):
		if l1[i] != 0:
			l.append(l1[i])
			l2.append(l1[i])
		else:
			c += 1
	l.sort(reverse=True)
	l2.sort()
	f = 0
	su = 0
	for i in range(len(l)):
		su += l[i]
		if su == 0:
			f = 1
			break
	su = 0
	f1 = 0
	for i in range(len(l2)):
		su += l2[i]
		if su == 0:
			f1 = 1
			break
	if f == 0 and len(l) > 0:
		l += [0] * c
		print('YES')
		print(*l)
	elif f1 == 0 and len(l2) > 0:
		l2 += [0] * c
		print('YES')
		print(*l2)
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().strip().split()))[:n]
	B = []
	sum = 0
	for i in range(n):
		sum += A[i]
	if sum != 0:
		print('YES')
		if sum < 0:
			for i in range(n):
				if A[i] < 0:
					B.append(A[i])
			for i in range(n):
				if A[i] > 0:
					B.append(A[i])
			for i in range(n):
				if A[i] == 0:
					B.append(A[i])
		else:
			for i in range(n):
				if A[i] > 0:
					B.append(A[i])
			for i in range(n):
				if A[i] < 0:
					B.append(A[i])
			for i in range(n):
				if A[i] == 0:
					B.append(A[i])
		sB = [str(b) for b in B]
		print(' '.join(sB))
	else:
		print('NO')


import math

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if sum(a) == 0:
		return 'NO'
	if sum(a) > 0:
		print('YES')
		return ' '.join(map(str, reversed(a)))
	if sum(a) < 0:
		print('YES')
		return ' '.join(map(str, a))
t = int(input())
while t > 0:
	t -= 1
	print(solve())


t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	if all([i == 0 for i in li]) or sum(li) == 0:
		print('NO')
	else:
		print('YES')
		k = 0
		for i in li:
			if i == 0:
				k += 1
		li = [i for i in li if i != 0]
		pos = [i for i in li if i > 0]
		neg = [i for i in li if i < 0]
		if sum(pos) > abs(sum(neg)):
			print(*pos, *neg, *[0] * k)
		else:
			print(*neg, *pos, *[0] * k)


for _ in range(int(input(''))):
	n = int(input(''))
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	if sum(a) > 0:
		a.sort(reverse=True)
	else:
		a.sort()
	print('YES')
	to_print = str(a[0])
	for i in range(1, n):
		to_print += ' ' + str(a[i])
	print(to_print)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	j = 0
	k = 0
	b = []
	c = []
	for i in range(n):
		if a[i] <= 0:
			k += a[i]
			b.append(a[i])
		else:
			j += a[i]
			c.append(a[i])
	if -k > j:
		print('YES')
		r = b + c
		print(*r)
	elif -k < j:
		print('YES')
		r = c + b
		print(*r)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		pos = 0
		neg = 0
		for i in a:
			if i > 0:
				pos += i
			else:
				neg += -i
		if pos > neg:
			print(' '.join([str(i) for i in a[::-1]]))
		else:
			print(' '.join([str(i) for i in a]))


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		arr = [int(i) for i in input().split()]
		count = 0
		j = 0
		if sum(arr) == 0:
			print('NO')
		else:
			print('YES')
			arr = sorted(arr)
			neg = 0
			pos = 0
			neg_arr = []
			pos_arr = []
			s = ''
			for i in range(n):
				if arr[i] <= 0:
					neg += arr[i]
					neg_arr.append(arr[i])
				else:
					pos += arr[i]
					pos_arr.append(arr[i])
			if abs(pos) > abs(neg):
				for i in pos_arr:
					s = s + str(i) + ' '
				for i in neg_arr:
					s = s + str(i) + ' '
			else:
				for i in neg_arr:
					s = s + str(i) + ' '
				for i in pos_arr:
					s = s + str(i) + ' '
			print(s)
main()


import sys
input = sys.stdin.readline

def solution(n, a):
	sol = []
	pos = []
	neg = []
	zeros = []
	if sum(a) == 0:
		print('NO')
		return
	pos = [elem for elem in a if elem > 0]
	zeros = [elem for elem in a if elem == 0]
	neg = [elem for elem in a if elem < 0]
	print('YES')
	if len(neg) == 0 or (len(pos) > 0 and sum(pos) >= abs(sum(neg))):
		sol += pos
		sol += zeros
		sol += neg
	else:
		sol += neg
		sol += zeros
		sol += pos
	print(*sol)
T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	solution(n, a)


t = int(input())
for inh in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		(pos, neg, k) = ([], [], 0)
		for i in range(0, n):
			if a[i] == 0:
				k += 1
			elif a[i] > 0:
				pos.append(a[i])
			else:
				neg.append(a[i])
		(a, b) = (sum(pos), abs(sum(neg)))
		if a > b:
			print(*pos, end=' ')
			print(*neg, end=' ')
		else:
			print(*neg, end=' ')
			print(*pos, end=' ')
		print('0 ' * k)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = 0
	for i in a:
		x += i
	if x == 0:
		print('NO')
	else:
		print('YES')
		if x > 0:
			a = sorted(a, reverse=True)
		else:
			a = sorted(a)
		print(*a, sep=' ')


for j in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	else:
		neg = 0
		pos = 0
		print('YES')
		for ele in l:
			if ele < 0:
				neg += ele
			else:
				pos += ele
		if pos > abs(neg):
			print(*sorted(l, reverse=True))
		else:
			print(*sorted(l))


cases = int(input())
for i in range(cases):
	length = int(input())
	array = list(map(int, input().split()))
	if sum(array) == 0:
		print('NO')
	elif sum(array) > 0:
		array.sort(reverse=True)
		print('YES')
		print(' '.join(map(str, array)))
	else:
		array.sort()
		print('YES')
		print(' '.join(map(str, array)))


t = int(input())
while t > 0:
	in1 = input()
	in2 = input().split()
	in2 = list(map(int, in2))
	k = ' '
	s = sum(in2)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			in2.sort(reverse=True)
		else:
			in2.sort()
		listToStr = ' '.join(map(str, in2))
		print(listToStr)
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	N = []
	P = []
	for a in A:
		if a >= 0:
			P.append(a)
		else:
			N.append(a)
	P.sort(reverse=True)
	N.sort()
	if sum(P) > -sum(N):
		B = P + N
		print('YES')
		print(*B)
	elif sum(P) < -sum(N):
		B = N + P
		print('YES')
		print(*B)
	else:
		print('NO')


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			a = [int(x) for x in R().split()]
			if sum(a) == 0:
				ans.append('NO')
				continue
			a.sort()
			flg = 1
			total = 0
			for j in range(n):
				total += a[j]
				if total == 0:
					for k in range(j + 1, n):
						if total - a[j] + a[k] != 0:
							total += a[k] - a[j]
							(a[j], a[k]) = (a[k], a[j])
							break
				if total == 0:
					flg = 0
					break
			if flg:
				ans.append('YES')
				ans.append(' '.join([str(a[j]) for j in range(n)]))
			else:
				a.sort(reverse=True)
				total = 0
				for j in range(n):
					total += a[j]
					if total == 0:
						total -= a[j]
						for k in range(j + 1, n):
							if total + a[k] != 0:
								total += a[k]
								(a[j], a[k]) = (a[k], a[j])
								break
				ans.append('YES')
				ans.append(' '.join([str(a[j]) for j in range(n)]))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		if sum(a) == 0:
			print('NO')
		else:
			print('YES')
			(ns, ps) = (0, 0)
			for e in a:
				if e > 0:
					ps += e
				else:
					ns -= e
			if ps > ns:
				print(*sorted(a, reverse=True))
			else:
				print(*sorted(a))
main()


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from fractions import Fraction
from decimal import Decimal
import math
mod = pow(10, 9) + 7

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

def lit():
	return list(sp())

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	n = int(input())
	l = lit()
	l.sort(reverse=True)
	if sum(l) != 0:
		print('YES')
		if sum(l) < 0:
			l = l[::-1]
		print(*l)
	else:
		print('NO')


import sys

def solve():
	n = int(input())
	d = list(map(int, input().split()))
	s = sum(d)
	if s == 0:
		print('NO')
		return 0
	c = d.count(0)
	if s < 0:
		a = sorted(d)
	else:
		a = sorted(d, reverse=True)
	a = list(filter(lambda x: x != 0, a))
	a += [0] * c
	print('YES')
	print(' '.join(map(str, a)))
for t in range(int(input())):
	solve()


t = int(input())
while t > 0:
	n = int(input())
	s = 0
	a = list(map(int, input().split(' ')))
	t -= 1
	for i in a:
		s += i
	if s == 0:
		print('NO')
		continue
	a.sort()
	if s > 0:
		a.reverse()
	print('YES')
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	l = sorted(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		print(' '.join(map(str, l[::-1])))
	else:
		print('YES')
		print(' '.join(map(str, l)))


rw = int(input())
for wewq in range(rw):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	a.sort()
	print('YES')
	if sum(a) > 0:
		a.reverse()
	for i in a:
		print(i, end=' ')
	print('')


t = int(input())
for i in range(t):
	a = input()
	l = list(map(int, input().split()))
	p_l = []
	m_l = []
	p_c = 0
	m_c = 0
	for v in l:
		if v > 0:
			p_l.append(v)
			p_c += v
		else:
			m_l.append(v)
			m_c += v
	if abs(m_c) == p_c:
		print('NO')
		continue
	print('YES')
	if abs(m_c) > p_c:
		answer = sorted(m_l) + p_l
	else:
		answer = sorted(p_l, reverse=True) + m_l
	for v in answer:
		print(v, end=' ')
	print()


inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def results(arr, n):
	s = sum(arr)
	if s == 0:
		return ['NO']
	elif s > 0:
		return ['YES', sorted(arr, reverse=True)]
	else:
		return ['YES', sorted(arr)]

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = seq()
		result = results(a, n)
		if len(result) == 1:
			print(result[0])
		else:
			print(result[0])
			print(*result[1])
main()


from itertools import accumulate
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	p = list(accumulate(a))
	c = a[::-1]
	q = list(accumulate(c))
	if 0 in p and 0 in q:
		print('NO')
	else:
		print('YES')
		if 0 in p:
			print(*c)
		elif 0 in q:
			print(*a)
		else:
			print(*a)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)
from collections import deque
from itertools import permutations
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	pos = []
	neg = []
	for i in a:
		if i > 0:
			pos.append(i)
		else:
			neg.append(i)
	pos.sort()
	neg.sort()
	if sum(a) == 0:
		print('NO')
	else:
		pr('YES')
		sm = 0
		a.sort()
		for i in a:
			if sm + i == 0:
				pr(*a[::-1])
				break
			sm += i
		else:
			pr(*a)


T = int(input())
for case in range(T):
	i = int(input())
	ls = [int(x) for x in input().split()]
	s = sum(ls)
	if s == 0:
		print('NO')
		continue
	lsp = [x for x in ls if x > 0]
	lsn = [x for x in ls if x < 0]
	zeros = [x for x in ls if x == 0]
	if s > 0:
		ret = lsp + lsn + zeros
	else:
		ret = lsn + lsp + zeros
	print('YES')
	print(' '.join([str(x) for x in ret]))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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

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

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

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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

def solve(case):
	n = int(inp())
	a = lis()
	if sum(a) == 0:
		print('NO')
		return
	print('YES')
	if sum(a) > 0:
		a = sorted(a)[::-1]
	else:
		a = sorted(a)
	print(' '.join((str(a[i]) for i in range(n))))
testcase(int(inp()))


for inx in range(int(input())):
	n = input()
	l = sorted(list(map(int, input().split())))
	s = sum(l)
	if s > 0:
		print('YES')
		print(*l[::-1])
	elif s < 0:
		print('YES')
		print(*l)
	else:
		print('NO')


for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	s = sum(a)
	print(*(s and ['YES'] + a[::1 - 2 * (s > 0)] or ['NO']))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	k = sum(a)
	if k == 0:
		print('NO')
	else:
		print('YES')
		if k < 0:
			a.sort()
		else:
			a.sort(reverse=True)
		for i in range(n):
			print(a[i], end=' ')
		print()


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [0] * T
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	M = sum(A)
	if M == 0:
		print('NO')
	elif M > 0:
		A.sort(reverse=True)
		print('YES')
		print(*A)
	else:
		A.sort()
		print('YES')
		print(*A)


def function():
	n = int(input())
	a = list(map(int, input().split()))
	temp = []
	b = []
	flag = 0
	if sum(a) == 0:
		print('NO')
	else:
		sum1 = 0
		sum2 = 0
		for i in a:
			if i > 0:
				sum1 = sum1 + i
				temp.append(i)
		for i in a:
			if i < 0:
				sum2 = sum2 + i
				temp.append(i)
		if abs(sum1) < abs(sum2):
			temp.reverse()
		for i in a:
			if i == 0:
				temp.append(i)
		s_um = 0
		for value in temp:
			s_um = s_um + value
			if s_um == 0:
				print('NO')
				flag = 1
				return
		if flag == 0:
			print('YES')
			print(*temp)
	return
tests = int(input())
for test in range(tests):
	function()


def print_arr(arr):
	for (i, ch) in enumerate(arr):
		if i == len(arr) - 1:
			print(ch)
		else:
			print(ch, end=' ')
	if not arr:
		print()

def run(arr):
	s = sum(arr)
	if s == 0:
		print('NO')
	elif s < 0:
		arr.sort()
		print('YES')
		print_arr(arr)
	else:
		arr.sort(reverse=True)
		print('YES')
		print_arr(arr)
n = int(input())
for _ in range(n):
	_ = input()
	s = input()
	s = [int(i) for i in s.split(' ')]
	run(s)


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		print('YES')
		(x, y) = ([], [])
		for i in l:
			if i < 0:
				y.append(i)
			else:
				x.append(i)
		if s < 0:
			print(*y + x)
		else:
			x.sort(reverse=True)
			print(*x + y)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		return
	c0 = len(list(filter(lambda x: x == 0, a)))
	pos = list(filter(lambda x: x > 0, a))
	neg = list(filter(lambda x: x < 0, a))
	neg.sort()
	ans = pos
	s = sum(ans)
	negsum = sum(neg)
	if abs(negsum) < s:
		ans += neg
	else:
		ans = neg + pos
	ans += c0 * [0]
	print('YES')
	print(*ans)
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


testcaes = int(input())
for testcase in range(testcaes):
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	arr = []
	ansarr = []
	for i in temparr:
		arr.append(int(i))
	totalsum = sum(arr)
	if totalsum == 0:
		print('NO')
	arr = sorted(arr)
	pos = 0
	neg = 0
	sumpos = 0
	sumneg = 0
	numzero = 0
	for i in arr:
		if i < 0:
			neg += 1
			sumneg += i
		elif i > 0:
			pos += 1
			sumpos += i
		else:
			numzero += 1
	sumnegabs = abs(sumneg)
	if sumnegabs > sumpos:
		for i in arr:
			ansarr.append(str(i))
		print('YES')
		print(' '.join(ansarr))
		continue
	if sumpos > sumnegabs:
		arr = arr[::-1]
		for i in arr:
			ansarr.append(str(i))
		print('YES')
		print(' '.join(ansarr))
		continue


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	s = 0
	for i in a:
		s += i
		if s == 0:
			break
	else:
		print('YES')
		print(*a)
		continue
	a.reverse()
	s = 0
	for i in a:
		s += i
		if s == 0:
			break
	else:
		print('YES')
		print(*a)
		continue
	print('NO')


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

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

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

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

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

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

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print(*a)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	s = sum(A)
	if not s:
		print('NO')
	else:
		pos = [a for a in A if a >= 0]
		pos.sort(reverse=True)
		neg = [a for a in A if a < 0]
		if s > 0:
			ans = pos + neg
		else:
			ans = neg + pos
		print('YES')
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sm = sum(arr)
	if sm == 0:
		print('NO')
	else:
		print('YES')
		if sm < 0:
			arr = sorted(arr)
		else:
			arr = sorted(arr)[::-1]
		for j in arr[:]:
			print(j, end=' ')
		print()


for t in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split()))
	numbers.sort()
	if sum(numbers) == 0:
		print('NO')
	elif sum(numbers) < 0:
		print('YES')
		print(*numbers)
	else:
		print('YES')
		print(*numbers[::-1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if sum(a) == 0:
		print('NO')
	else:
		if sum(a) > 0:
			a.reverse()
		print('YES')
		for j in range(n):
			print(a[j], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum1 = 0
	flag = 0
	for i in range(n):
		if sum1 + a[i] == 0:
			flag = 1
			break
		sum1 += a[i]
	if flag == 0:
		print('YES')
		print(*a)
		continue
	a = a[::-1]
	sum1 = 0
	flag = 0
	for i in range(n):
		if sum1 + a[i] == 0:
			flag = 1
			break
		sum1 += a[i]
	if flag == 0:
		print('YES')
		print(*a)
		continue
	else:
		print('NO')


for tt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	(sm1, sm2) = (0, 0)
	for i in a:
		if i > 0:
			sm1 += i
		else:
			sm2 += i
	print('YES')
	if sm1 > abs(sm2):
		print(*sorted(a, reverse=True))
	else:
		print(*sorted(a))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	array = list(map(int, input().split()))
	if sum(array) == 0:
		print('NO')
		continue
	elif sum(array) > 0:
		array = reversed(sorted(array))
	elif sum(array) < 0:
		array = sorted(array)
	arr = ' '
	print('YES')
	array = map(str, array)
	print(arr.join(array))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		i = 1
		while i < len(a):
			if sum(a[:i + 1]) == 0 and i < len(a) - 1:
				(a[i], a[i + 1]) = (a[i + 1], a[i])
			i += 1
		print(*sorted(a, reverse=sum(a) > 0))


n = int(input())
ans = []
for i in range(n):
	k = int(input())
	sum = 0
	a = [int(x) for x in input().split()]
	for t in a:
		sum += t
	if sum:
		ans.append('YES')
		if sum > 0:
			a.sort(reverse=True)
			ans.append(' '.join(map(str, a)))
		else:
			a.sort()
			ans.append(' '.join(map(str, a)))
	else:
		ans.append('NO')
for h in ans:
	print(h)


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

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

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

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	n = inp()
	a = list(minp())
	count = 0
	for i in range(n):
		count += a[i]
	if count != 0:
		print('YES')
		new = []
		for i in range(n):
			if a[i] != 0:
				new.append(a[i])
		if count > 0:
			new.sort(reverse=True)
			for i in range(n - len(new)):
				new.append(0)
		else:
			new.sort()
			for i in range(n - len(new)):
				new.append(0)
		print(*new)
	else:
		print('NO')


t = int(input())
for t in range(0, t):
	a = []
	sum1 = 0
	sum2 = 0
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	flag = 0
	for i in range(0, n):
		if a[i] < 0:
			sum2 = sum2 + a[i]
		else:
			sum1 = sum1 + a[i]
	sum2 = -1 * sum2
	if sum1 == sum2:
		print('NO')
	else:
		print('YES')
		if sum1 > sum2:
			a.sort(reverse=True)
		else:
			a.sort()
		for i in range(0, n):
			print(a[i])
			print(' ')
		print('\n')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		a = arr[:]
		a.sort(reverse=True)
		arr.sort()
		s = 0
		fl = 0
		for d in a:
			s += d
			if s == 0:
				fl = 1
		if fl == 0:
			a = map(str, a)
			print(' '.join(a))
		else:
			arr = map(str, arr)
			print(' '.join(arr))


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		l.sort(reverse=True)
		print('YES')
		print(*l)
	else:
		print('YES')
		l.sort()
		print(*l)
t = int(input())
for _ in range(t):
	solution()


def solve(a):
	s = sum(a)
	if s == 0:
		print('NO')
		return
	a.sort()
	if s > 0:
		a.reverse()
	print('YES')
	for x in a:
		print(x, end=' ')
t = int(input())
lists = []
for i in range(t):
	n = int(input())
	lst = [int(x) for x in input().split()]
	arr = [n, lst]
	lists.append(arr)
for list in lists:
	solve(list[1])


test = int(input())
for t in range(test):
	n = int(input())
	lt = list(map(int, input().split()))
	lst = sorted(lt)
	if sum(lst) == 0:
		print('NO')
	elif sum(lst) < 0:
		print('YES')
		print(*lst)
	else:
		print('YES')
		tmp = []
		for i in range(n - 1, -1, -1):
			tmp.append(lst[i])
		print(*tmp)


for _ in range(int(input())):
	n = int(input())
	A = [int(_) for _ in input().split()]
	if sum(A) == 0:
		print('NO')
	else:
		print('YES')
		(x, y) = (0, 0)
		for _ in range(n):
			if A[_] < 0:
				x += A[_]
			else:
				y += A[_]
		if abs(x) > y:
			print(*sorted(A))
		else:
			print(*sorted(A, reverse=True))


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


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
for _ in range(vary(1)):
	n = vary(1)
	num = array_int()
	if sum(num) == 0:
		print('NO')
		continue
	pos = neg = 0
	tt = []
	for i in range(n):
		if num[i] > 0:
			pos += num[i]
		elif num[i] < 0:
			neg += abs(num[i])
	if pos > neg:
		num.sort(reverse=True)
		print('YES')
		print(*num)
	else:
		num.sort()
		print('YES')
		print(*num)


for _ in range(int(input())):
	input()
	nums = list(map(int, input().split()))
	s = sum(nums)
	if s == 0:
		print('NO')
	else:
		nums = sorted(nums, reverse=s > 0)
		print('YES')
		print(' '.join(map(str, nums)))


exec("for i in range(int(input())):\n input()\n l = list(map(int, input().split()))\n if not sum(l):\n  print('NO')\n  continue\n print('YES')\n if sum(filter(lambda x: x > 0, l))  > -sum(filter(lambda x: x < 0, l)):\n  print(*sorted(list(filter(lambda x: x, l)))[::-1], end = ' ')\n  print('0 ' * l.count(0))\n  continue\n print(*sorted(list(filter(lambda x: x, l))), end = ' ')\n print('0 ' * l.count(0))")


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	zeros = a.count(0)
	sm = sum(a)
	if sm == 0:
		print('NO')
	else:
		res = [x for x in sorted(a, reverse=sm > 0) if x != 0] + [0 for k in range(zeros)]
		print('YES')
		print(*res)


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

def solve(N, A):
	neg = [x for x in A if x < 0]
	pos = [x for x in A if x > 0]
	zero = [x for x in A if x == 0]
	negTotal = abs(sum(neg))
	posTotal = sum(pos)
	if negTotal == posTotal:
		return 'NO'
	if negTotal < posTotal:
		B = pos + neg + zero
	else:
		B = neg + pos + zero
	return 'YES\n' + ' '.join(map(str, B))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(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 q in range(t):
	n = int(input())
	mas = list(map(int, input().split()))
	mas.sort()
	if sum(mas) == 0:
		print('NO')
	else:
		print('YES')
		if sum(mas) > 0:
			mas = mas[::-1]
		for i in mas:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	neg = [a for a in A if a < 0]
	pos = [a for a in A if a > 0]
	zero = [a for a in A if a == 0]
	ns = -sum(neg)
	ps = sum(pos)
	if ns > ps:
		print('YES')
		print(*neg + pos + zero)
	elif ns < ps:
		print('YES')
		print(*pos + neg + zero)
	else:
		print('NO')


def solve():
	n = int(input())
	a = sorted(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		if sum(a) > 0:
			a = a[::-1]
		print('YES')
		print(' '.join(map(str, a)))
t = int(input())
for i in range(t):
	solve()


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

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

def li():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	n = ii()
	a = li()
	a.sort()
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if sum(a) > 0:
			a = a[::-1]
		for i in a:
			print(i, end=' ')
		print()


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	a.sort()
	if sum(a) > 0:
		a.reverse()
	print('YES')
	print(*a)


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
q = I()
for _ in range(q):
	n = I()
	A = readInts()
	total = sum(A)
	A = sorted(A)
	if total == 0:
		print('NO')
	else:
		print('YES')
		wa = 0
		for i in range(n):
			wa += A[i]
			if wa == 0:
				(A[i], A[i - 1]) = (A[i - 1], A[i])
		wa = 0
		ok = True
		for i in range(n):
			wa += A[i]
			if wa == 0:
				ok = False
		if ok:
			print(*A)
			continue
		A = sorted(A, reverse=True)
		wa = 0
		for i in range(n):
			wa += A[i]
			if wa == 0:
				(A[i], A[i - 1]) = (A[i - 1], A[i])
		print(*A)
		continue


for test in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		print(*a[::-1])
	else:
		print('YES')
		print(*a)


n_sets = int(input())
for i in range(n_sets):
	n = int(input())
	a = list(map(int, input().split()))
	apos = []
	aneg = []
	spos = sneg = n0 = 0
	for x in a:
		if x > 0:
			apos.append(x)
			spos += x
		elif x < 0:
			aneg.append(x)
			sneg += x
		else:
			n0 += 1
	s = spos + sneg
	if s == 0:
		print('NO')
	else:
		print('YES')
		if spos > abs(sneg):
			print(*apos, *aneg, *[0] * n0)
		else:
			print(*aneg, *apos, *[0] * n0)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l.sort(reverse=True)
		for i in range(len(l)):
			print(l[i], end=' ')
	elif sum(l) < 0:
		print('YES')
		l.sort()
		for i in range(len(l)):
			print(l[i], end=' ')


from sys import stdin
T = int(stdin.readline().strip())
for caso in range(T):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	s.sort()
	neg = 0
	pos = 0
	for i in range(n):
		if s[i] < 0:
			neg += abs(s[i])
		else:
			pos += s[i]
	if pos == neg:
		print('NO')
	else:
		print('YES')
		if pos > neg:
			s = s[::-1]
			print(*s)
		else:
			print(*s)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		p = []
		o = []
		for i in range(len(a)):
			if a[i] >= 0:
				p.append(a[i])
			else:
				o.append(a[i])
		p.sort(reverse=True)
		o.sort(reverse=True)
		if abs(sum(p)) > abs(sum(o)):
			print('YES')
			print(*p, *o)
		else:
			print('YES')
			print(*o, *p)


from math import *
import sys
from sys import stdin
from sys import stdout
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if sum(ar) == 0:
		print('NO')
	else:
		print('YES')
		if sum(ar) > 0:
			ar.sort(reverse=True)
			print(*ar)
		else:
			ar.sort()
			print(*ar)


t = int(input())
while t >= 1:
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	c = 0
	for a in x:
		c += a
	if c == 0:
		print('NO')
	elif c > 0:
		x.reverse()
		print('YES')
		for a in x:
			print(a, ' ', end='')
		print()
	else:
		print('YES')
		for a in x:
			print(a, ' ', end='')
		print()
	t = t - 1


testcase = int(input())
for test in range(testcase):
	n = int(input())
	li = list(map(int, input().split()))
	s = 0
	pos = []
	neg = []
	zeros = []
	possum = 0
	negsum = 0
	for item in li:
		s += item
	if s == 0:
		print('NO')
	else:
		print('YES')
		for item in li:
			if item > 0:
				pos.append(item)
				possum += item
			elif item < 0:
				neg.append(item)
				negsum += item
			else:
				zeros.append(item)
		if possum > negsum * -1:
			for item in pos:
				print(item, end=' ')
			for item in neg:
				print(item, end=' ')
			for item in zeros:
				print(item, end=' ')
		else:
			for item in neg:
				print(item, end=' ')
			for item in pos:
				print(item, end=' ')
			for item in zeros:
				print(item, end=' ')


import bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string

def repeat(_func=None, *, times=1):

	def decorator(func):

		@functools.wraps(func)
		def wrapper(*args, **kwargs):
			for _ in range(times):
				func(*args, **kwargs)
		return wrapper
	if _func is None:
		return decorator
	else:
		return decorator(_func)

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
	return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):
	return [int(input()) for _ in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def getmatrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def display_matrix(mat):
	for i in range(len(mat)):
		print(mat[i])

def factor(n):
	d = collections.defaultdict(int)
	while not n % 2:
		d[2] += 1
		n //= 2
	i = 3
	while i * i <= n:
		while not n % i:
			d[i] += 1
			n //= i
		i += 2
	if n > 1:
		d[n] += 1
	return d

@repeat(times=getint())
def main():
	n = getint()
	a = s_unpack()
	s = sum(a)
	if not s:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.reverse()
		print(*a)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(b, c) = ([], [])
	for e in a:
		if e < 0:
			b.append(e)
		else:
			c.append(e)
	if -sum(b) == sum(c):
		print('NO')
	elif -sum(b) > sum(c):
		print('YES')
		print(*b + c)
	else:
		print('YES')
		print(*list(reversed(sorted(c))) + b)


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		s = 0
		notzero = 0
		for j in range(n):
			s += li[j]
			if s == 0:
				a = li[0]
				li = li[1:] + [a]
				notzero = 1
				break
		if notzero == 0:
			flag = 1
			print('YES')
			for i in li:
				print(i, end=' ')
			print()
			break
	if flag == 0:
		print('NO')
	t -= 1


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	sn = 0
	sp = 0
	for i in a:
		if i >= 0:
			sp += i
		else:
			sn -= i
	if sp == sn:
		print('NO')
	elif sp > sn:
		print('YES')
		print(*sorted(a, reverse=True))
	else:
		print('YES')
		print(*sorted(a))


import collections
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().strip(' ').split(' ')))
	positive = []
	negative = []
	zero = []
	for i in arr:
		if i > 0:
			positive.append(i)
		elif i < 0:
			negative.append(i)
		else:
			zero.append(0)
	if sum(positive) > -1 * sum(negative):
		print('YES')
		print(' '.join((str(i) for i in positive)) + ' ' + ' '.join((str(i) for i in negative)) + ' ' + ' '.join((str(i) for i in zero)))
	elif sum(positive) < -1 * sum(negative):
		print('YES')
		print(' '.join((str(i) for i in negative)) + ' ' + ' '.join((str(i) for i in positive)) + ' ' + ' '.join((str(i) for i in zero)))
	else:
		print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

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

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=2):
	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):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

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

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for _ in range(ii()):
		nn = ii()
		arr = li()
		p = []
		n = []
		res = []
		z = []
		for ele in arr:
			if ele < 0:
				n.append(ele)
			elif ele == 0:
				z.append(ele)
			else:
				p.append(ele)
		if sum(p) + sum(n) == 0:
			print('NO')
		elif abs(sum(p)) > abs(sum(n)):
			print('YES')
			print(*p, *n, *z)
		else:
			print('YES')
			print(*n, *p, *z)
main()


def avoid_zero(arr):
	if sum(arr) == 0:
		return []
	neg = 0
	pos = 0
	for i in arr:
		if i < 0:
			neg += i
		elif i > 0:
			pos += i
	if abs(neg) > pos:
		arr.sort()
	else:
		arr.sort(reverse=True)
	return arr
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = avoid_zero(arr)
	if res:
		print('YES')
		print(*res, sep=' ')
	else:
		print('NO')


import sys, os, io
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for tc in range(1, 1 + int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if s > 0:
			a.reverse()
		print(*a)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l.sort()
		l.reverse()
		for t in l:
			print(t, end=' ')
	else:
		print('YES')
		l.sort()
		for t in l:
			print(t, end=' ')


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	ans = True
	for i in a:
		s = s + i
		if s == 0:
			ans = False
			break
	if not ans:
		a.sort()
		s = 0
		ans = True
		for i in a:
			s = s + i
			if s == 0:
				ans = False
				break
	if ans:
		print('YES')
		print(*a)
	else:
		print('NO')


for i in range(int(input())):
	num = int(input())
	Ans = sorted(list(map(int, input().split())))
	if sum(Ans) == 0:
		print('No')
	else:
		print('Yes')
		if sum(Ans) > 0:
			print(*Ans[::-1])
		else:
			print(*Ans)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = []
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	if sum(A) == 0:
		Ans.append('NO')
	else:
		Ap = [a for a in A if a > 0]
		Am = [a for a in A if a < 0]
		Az = [a for a in A if a == 0]
		if abs(sum(Ap)) < abs(sum(Am)):
			(Am, Ap) = (Ap, Am)
		B = Ap + Am + Az
		Ans.append('YES')
		Ans.append(' '.join(map(str, B)))
print('\n'.join(Ans))


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	a.sort()
	if sum(a) == 0:
		print('NO')
	else:
		(po, ne) = ([], [])
		for i in a:
			if i > 0:
				po.append(i)
			else:
				ne.append(i)
		poss = []
		po.sort()
		ne.sort()
		ner = ne.copy()
		ner.sort(reverse=True)
		por = po.copy()
		por.sort(reverse=True)
		poss = []
		poss.append(po.copy() + ne.copy())
		poss.append(po.copy() + ner.copy())
		poss.append(por.copy() + ne.copy())
		poss.append(por.copy() + ner.copy())
		poss.append(ne.copy() + po.copy())
		poss.append(ne.copy() + por.copy())
		poss.append(ner.copy() + po.copy())
		poss.append(ne.copy() + por.copy())
		found = False
		for arr in poss:
			s = 0
			imposs = False
			for i in range(n):
				s += arr[i]
				if s == 0:
					imposs = True
					break
			if not imposs:
				print('YES')
				print(*arr)
				found = True
				break
		if not found:
			print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		b = []
		for v in a:
			if v != 0:
				b.append(v)
		b.sort(reverse=True)
		for i in range(n - len(b)):
			b.append(0)
		print('YES')
		print(*b)
	elif sum(a) < 0:
		b = []
		for v in a:
			if v != 0:
				b.append(v)
		b.sort()
		for i in range(n - len(b)):
			b.append(0)
		print('YES')
		print(*b)

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if abs(sum(filter(lambda x: x > 0, a))) > abs(sum(filter(lambda x: x < 0, a))):
		a = sorted(a, reverse=True)
	else:
		a = sorted(a)
	for i in range(1, n):
		if sum(a[0:i]) == 0:
			a.append(a.pop(i))
			i = i - 1
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		print(' '.join((str(i) for i in a)))


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(l) < 0:
			l.sort()
			print(*l)
		else:
			l.sort(reverse=True)
			print(*l)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	arr.sort()
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		print(*arr[::-1])
	else:
		print('YES')
		print(*arr)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	zeros = a.count(0)
	while True:
		try:
			a.remove(0)
		except:
			break
	if sum(a) == 0:
		print('NO')
		continue
	elif sum(a) > 0:
		a.sort(reverse=True)
		a += [0] * zeros
		print('YES')
		print(*a)
	else:
		print('YES')
		a.sort()
		a += [0] * zeros
		print(*a)


import sys
input = lambda : sys.stdin.readline().strip()
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	elif s < 0:
		print('YES')
		print(*sorted(a))
	else:
		print('YES')
		print(*sorted(a, key=lambda x: -x))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
		continue
	print('YES')
	zero = l.count(0)
	positive = list(filter(lambda x: x > 0, l))
	s_p = sum(positive)
	negative = list(filter(lambda x: x < 0, l))
	if s > 0:
		print(*positive + negative + [0] * zero)
	else:
		print(*negative + positive + [0] * zero)


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
from operator import itemgetter
for _ in range(II()):
	n = II()
	lst = LI()
	pos = []
	neg = []
	flag = 0
	sum1 = 0
	if sum(lst) == 0:
		print('NO')
		continue
	for i in range(n):
		if lst[i] < 0:
			neg.append(lst[i])
		else:
			pos.append(lst[i])
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	if sum(pos) > abs(sum(neg)):
		lst = pos + neg
	else:
		lst = neg + pos
	print('YES')
	for i in range(n):
		print(lst[i], end=' ')
	print()


k = int(input())
for r in range(0, k):
	n = int(input())
	a = input().split()
	pos = 0
	neg = 0
	s = 0
	for i in range(0, n):
		a[i] = int(a[i])
		if a[i] > 0:
			pos = pos + a[i]
		elif a[i] < 0:
			neg = neg + a[i]
	if abs(neg) > pos:
		a.sort()
	else:
		a.sort(reverse=True)
	if sum(a) == 0:
		print('NO')
		continue
	i = 1
	while i < n:
		if sum(a[0:i]) == 0:
			a.append(a.pop(i))
			i = i - 1
		i = i + 1
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		for i in a:
			print(i, end=' ')
		print('')


t = int(input())
for i in range(t):
	n = int(input())
	a = input().rsplit(' ')
	a = list(map(int, a))
	sum_condition_a = True
	sum_a = 0
	for x in a:
		sum_a += x
	if sum_a == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if sum_a > 0:
			ans = ''
			a.reverse()
			for x in a:
				ans = ans + str(x) + ' '
			print(ans)
		else:
			ans = ''
			for x in a:
				ans = ans + str(x) + ' '
			print(ans)


import sys, os.path
from collections import *
from heapq import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		summ = 0
		i = 0
		while i < n:
			if summ + l[i] == 0:
				l.append(l[0])
				del l[0]
				i = 0
				summ = 0
			else:
				summ += l[i]
				i += 1
		print(*l)


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	itog = n * [0]
	k = 0
	if sum(a) < 0:
		print('YES')
		print(*sorted(a))
	elif sum(a) == 0:
		print('NO')
	else:
		print('YES')
		c = sorted(a, reverse=True)
		print(*c)


import random

def SommeJusqua(A, i):
	s = 0
	for j in range(i):
		s = s + A[j]
	return s

def traitement(A):
	if sum(A) == 0:
		print('NO')
	elif len(A) == 1:
		print('YES\n' + ' '.join(map(str, A)))
	else:
		test = False
		compteur = 0
		while not test:
			B = A
			random.shuffle(B)
			compteur += 1
			j = 0
			for i in range(1, len(B) + 1):
				if SommeJusqua(B, i) == 0:
					j = 0
					break
				else:
					j += 1
			if j == len(B):
				test = True
				print('YES\n' + ' '.join(map(str, B)))
for i in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	traitement(A)


tes = int(input())
for t in range(tes):
	n = int(input())
	a = input().split()
	a = [int(i) for i in a]
	b = sorted(a)
	if sum(a) == 0:
		print('NO')
	elif sum(a) < 0:
		s = 'YES'
		for k in b:
			s += ' ' + str(k)
		print(s)
	elif sum(a) > 0:
		b.reverse()
		s = 'YES'
		for k in b:
			s += ' ' + str(k)
		print(s)


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	sol = []
	currSum = 0
	arr.sort()
	pos = 0
	neg = 0
	for i in arr:
		if i <= 0:
			neg += i * -1
		else:
			pos += i
	if neg < pos:
		arr = list(reversed(arr))
	if sum(arr) == 0:
		print('NO')
		return
	print('YES')
	arr = [str(x) for x in arr]
	print(' '.join(arr))
for i in range(t):
	solve()


n = int(input())
for i in range(n):
	b = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		for j in range(b):
			print(a[b - j - 1])
	else:
		print('YES')
		for j in range(b):
			print(a[j])


def avoidz(a):
	if sum(a) == 0:
		return ['NO']
	a.sort()
	b1 = a
	b2 = b1[::-1]
	b = []
	for i in range(len(a)):
		if sum(b1[:i + 1]) == 0:
			return ['YES', b2]
		if sum(b2[:i + 1]) == 0:
			break
	return ['YES', b1]
n = int(input())
res = []
for i in range(n):
	p = int(input())
	arr = list(map(int, input().split()))
	res.append(avoidz(arr))
for j in res:
	if len(j) != 1:
		print(j[0])
		print(*j[1])
	else:
		print(*j)


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')

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

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

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

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

	def S():
		return stdin.readline().rstrip()

	def Sn():
		return stdin.readline().split(' ')

def func(a):
	s = sum(a)
	if s == 0:
		return 'NO'
	if s > 0:
		a.sort(reverse=True)
		return 'YES\n' + ' '.join(map(str, a))
	a.sort()
	return 'YES\n' + ' '.join(map(str, a))
t = I()
answers = [''] * t
for i in range(t):
	n = I()
	l = list(In())
	answers[i] = func(l)
stdout.write('\n'.join(answers).rstrip())


import sys
import math
from sys import stdin
from functools import reduce
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().strip().split()))
	sm = sum(arr)
	if sm == 0:
		print('NO')
	else:
		print('YES')
		arr.sort()
		if sm > 0:
			print(*arr[::-1])
		else:
			print(*arr)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = inl()
	total = sum(a)
	if total == 0:
		print('NO')
	else:
		print('YES')
		print(*sorted(a, reverse=True if total > 0 else False))


def solve():
	n = int(input())
	l = sorted(list(map(int, input().split(' '))))
	s = l[::-1]
	x = sum(l)
	if x == 0:
		print('NO')
	elif x < 0:
		print('YES')
		print(' '.join((str(i) for i in l)))
	else:
		print('YES')
		print(' '.join((str(i) for i in s)))
for _ in range(int(input())):
	solve()


ca = int(input())
while ca > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	val = sum(a)
	if val > 0:
		print('Yes')
		print(*[i for i in a if i > 0], end=' ')
		print(*[i for i in a if i < 0], end=' ')
		print(*[i for i in a if i == 0], end='\n')
	if val < 0:
		print('Yes')
		print(*[i for i in a if i < 0], end=' ')
		print(*[i for i in a if i > 0], end=' ')
		print(*[i for i in a if i == 0], end='\n')
	if val == 0:
		print('No')
	ca = ca - 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	th = []
	done = []
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(l) > 0:
			l.sort(reverse=True)
			for i in range(n):
				print(l[i], end=' ')
			print()
		else:
			l.sort()
			for i in range(n):
				print(l[i], end=' ')
			print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split(' ')))
	Sum = sum(arr)
	if Sum == 0:
		print('NO')
		continue
	print('YES')
	arr.sort()
	if Sum > 0:
		arr = arr[::-1]
	for ele in arr:
		print(ele, end=' ')
	print()


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
		continue
	b = sorted(a, reverse=s > 0)
	if b[0] == 0:
		(b[1], b[0]) = (b[0], b[1])
	for j in reversed(range(n, 1)):
		s -= b[j]
		if s == 0:
			print(b[j])
			print('NO')
			break
	if s != 0:
		print('YES')
		print(' '.join(list(map(str, b))))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	summ = sum(l)
	if summ < 0:
		print('YES')
		print(*l)
	elif summ > 0:
		l.reverse()
		print('YES')
		print(*l)
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	asum = sum(a)
	if not asum:
		print('NO')
	else:
		print('YES')
		if asum > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		a = list(map(str, a))
		print(' '.join(a))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	arrs = sorted(a)
	ars = sorted(a, reverse=True)
	c = 0
	s = 0
	for i in arrs:
		s += i
		if s == 0:
			c = 1
			break
	print('YES')
	if c:
		print(*ars)
	else:
		print(*arrs)


for t in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	if sum(a) != 0:
		print('YES')
		if sum(a) > 0:
			a = sorted(a, reverse=True)
		print(*a, sep=' ')
	else:
		print('NO')


casos = input()
for a in range(int(casos)):
	l = int(input())
	array_1 = []
	val = str(input())
	array_1 = [int(x) for x in val.split()]
	sumaNegativa = 0
	sumaPositiva = 0
	total = sum(array_1)
	o = ''
	contador = 0
	if total == 0:
		print('NO')
		continue
	else:
		print('YES')
	for i in array_1:
		if i < 0:
			sumaNegativa = sumaNegativa + i
		else:
			sumaPositiva = sumaPositiva + i
	if sumaPositiva + sumaNegativa < 0:
		array_1.sort()
	if sumaPositiva + sumaNegativa > 0:
		array_1.sort(reverse=True)
	for n in array_1:
		contador = contador + n
		if contador == 0:
			array_1.append(n)
			array_1.remove(n)
	while array_1[0] == 0:
		array_1.append(array_1[0])
		del array_1[0]
	for y in array_1:
		o = o + ''.join(str(y)) + ' '
	print(o)


for k in [0] * int(input()):
	n = int(input())
	mas = list(map(int, input().split(' ')))
	s = sum(mas)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		mas.sort(reverse=True)
		print(*mas)
	else:
		print('YES')
		mas.sort()
		print(*mas)


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	a = inlt()
	if sum(a) == 0:
		print('NO')
		continue
	b = sorted(a)
	s = 0
	for num in b:
		s += num
		if s == 0:
			break
	else:
		print('YES')
		print(' '.join((str(x) for x in b)))
		continue
	print('YES')
	print(' '.join((str(x) for x in b[::-1])))


t = int(input())
q = []
for i in range(t):
	n = int(input())
	l = list(map(int, list(input().split())))
	if sum(l) == 0:
		q.append(['NO'])
	else:
		l.sort()
		q.append(['YES'])
		if sum(l) > 0:
			q.append(l[::-1])
		else:
			q.append(l)
for i in q:
	for j in i:
		print(j, end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def main():
	try:
		for _ in range(inp()):
			n = inp()
			a = inlt()
			s = sum(a)
			if s == 0:
				print('NO')
			elif s > 0:
				print('YES')
				print(*sorted(a, reverse=True), sep=' ')
			else:
				print('YES')
				print(*sorted(a), ' ')
	except Exception as e:
		print(e)
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')
main()


import sys

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	if sum(a) > 0:
		print(*sorted(a, reverse=True))
	else:
		print(*sorted(a))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	b = a.copy()
	a.sort()
	b.sort()
	b.reverse()
	flag = 0
	su = 0
	for i in range(n):
		su += a[i]
		if su == 0:
			flag += 1
			break
	if flag == 0:
		print('YES')
		print(*a, sep=' ')
		continue
	flag = 0
	su = 0
	for i in range(n):
		su += b[i]
		if su == 0:
			flag += 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
		print(*b, sep=' ')


def lis():
	return [int(x) for x in input().split()]

def intt():
	return int(input())
t = intt()
for i in range(t):
	n = intt()
	a = lis()
	pos = []
	neg = []
	zero = []
	for i in a:
		if i < 0:
			neg.append(i)
		elif i > 0:
			pos.append(i)
		else:
			zero.append(i)
	if sum(pos) + sum(neg) != 0 and len(zero) != n:
		print('YES')
		if sum(pos) > abs(sum(neg)):
			print(*pos + zero + neg)
		elif sum(pos) < abs(sum(neg)):
			print(*neg + zero + pos)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(sorted(map(int, input().split())))

	def judge(a):
		cum = 0
		for i in range(n):
			cum += a[i]
			if cum == 0:
				flag = True
				for k in range(i + 1, n):
					if a[k] != a[i]:
						cum += a[k] - a[i]
						tmp = a[i]
						a[i] = a[k]
						a[k] = tmp
						flag = False
						break
				if flag:
					return False
		return True
	if judge(a):
		print('YES')
		print(*a)
	elif judge(a[::-1]):
		print('YES')
		print(*a[::-1])
	else:
		print('NO')


def put():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(put())
	s = sum(l)
	if s == 0:
		print('NO')
	elif s > 0:
		l.sort(reverse=True)
		print('YES')
		print(*l)
	else:
		l.sort()
		print('YES')
		print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
		continue
	else:
		print('YES')
		print(*sorted(a, reverse=s > 0))


def arrayPrint(ar):
	for i in ar:
		print(i, end=' ')
tt = int(input())
while tt > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	pos = []
	neg = []
	zero = []
	for i in range(n):
		if arr[i] > 0:
			pos.append(arr[i])
		elif arr[i] < 0:
			neg.append(arr[i])
		elif arr[i] == 0:
			zero.append(arr[i])
	if sum(arr) == 0:
		print('NO')
	else:
		p = sum(pos)
		nn = sum(neg)
		if p > abs(nn):
			print('YES')
			arrayPrint(pos)
			arrayPrint(neg)
			arrayPrint(zero)
		elif p < abs(nn):
			print('YES')
			arrayPrint(neg)
			arrayPrint(pos)
			arrayPrint(zero)
	print()
	tt -= 1


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
		continue
	print('YES')
	(neg, pos) = (0, 0)
	for item in arr:
		if item >= 0:
			pos += item
		else:
			neg += abs(item)
	if neg > pos:
		for item in sorted(arr):
			print(item, end=' ')
	else:
		for item in sorted(arr)[::-1]:
			print(item, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	ar = [int(i) for i in input().split()]
	if sum(ar) and sum(ar) < 0:
		print('YES')
		print(*sorted(ar))
	elif sum(ar) and sum(ar) > 0:
		print('YES')
		print(*sorted(ar, reverse=True))
	else:
		print('NO')


from collections import deque
for _ in range(int(input())):
	n = int(input())
	arr = deque(sorted(list(map(int, input().split()))))
	if sum(arr) > 0:
		print('YES')
		print(*sorted(arr, reverse=True))
	elif sum(arr) < 0:
		print('YES')
		print(*sorted(arr))
	else:
		print('NO')


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
from random import shuffle

def check(x):
	t = x[0]
	if t == 0:
		return False
	for i in x[1:]:
		t += i
		if t == 0:
			return False
	return True
for _ in range(inp()):
	n = inp()
	x = ip()
	x.sort()
	if sum(x) == 0:
		print('NO')
	else:
		print('YES')
		while not check(x):
			shuffle(x)
		print(*x)


import sys
from collections import Counter

def solve(a):
	n = len(a)
	freqs = Counter(a)
	if sum(a) == 0:
		return None
	else:
		do_reverse = sum([x for x in a if x > 0]) > -sum([x for x in a if x < 0])
		keys = sorted(freqs.keys(), reverse=do_reverse)
		trailing_zeros = 0 if not 0 in freqs else freqs[0]
		del freqs[0]
		b = []
		for k in keys:
			b.extend([k] * freqs[k])
		b.extend([0] * trailing_zeros)
		return b
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
cur = 1
for ti in range(T):
	a = [int(x) for x in IN[cur + 1].split(' ')]
	b = solve(a)
	if b:
		print('YES')
		print(' '.join([str(x) for x in b]))
	else:
		print('NO')
	cur += 2


t = int(input())
for test_case in range(t):
	n = [int(x) for x in input().split()]
	n = n[0]
	a = [int(y) for y in input().split()]
	summ = 0
	for i in range(n):
		summ += a[i]
	if summ == 0:
		res = 'NO'
		print()
		print(res)
		print()
	elif summ > 0:
		res = 'YES'
		res2 = sorted(a, reverse=True)
		print()
		print(res)
		print(*res2)
		print()
	else:
		res = 'YES'
		res2 = sorted(a)
		print()
		print(res)
		print(*res2)
		print()


from copy import copy

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		if sum(a) == 0:
			print('NO')
		else:
			l = []
			(i, s) = (0, 0)
			a = sorted(a, reverse=True)
			b = copy(a)
			while i < n:
				for j in range(len(a)):
					if s + a[j] != 0:
						l.append(a[j])
						s += a[j]
						del a[j]
						break
				i += 1
			if len(l) == n:
				print('YES')
				print(*l)
			else:
				l = []
				(i, s) = (0, 0)
				a = sorted(b)
				while i < n:
					for j in range(len(a)):
						if s + a[j] != 0:
							l.append(a[j])
							s += a[j]
							del a[j]
							break
					i += 1
				print('YES')
				print(*l)
main()


N = int(input())
for _ in range(N):
	n = int(input())
	values = [int(i) for i in input().split()]
	if sum(values) == 0:
		print('NO')
	else:
		print('YES')
		negative_values = []
		positive_values = []
		for i in values:
			if i < 0:
				negative_values.append(i)
			else:
				positive_values.append(i)
		positive_values.sort(reverse=True)
		negative_values.sort(reverse=True)
		if abs(sum(negative_values)) > sum(positive_values):
			print(*negative_values + positive_values)
		else:
			print(*positive_values + negative_values)


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


t = int(input())
for i in range(t):
	input()
	li = [i for i in map(int, input().split())]
	s = sum(li)
	if s == 0:
		print('NO')
		continue
	li.sort(reverse=s > 0)
	print('YES\n', *li)


def calc(n, a):
	countzero = a.count(0)
	a = [item for item in a if item != 0]
	flag = False
	pos = []
	neg = []
	for item in a:
		if item > 0:
			pos.append(item)
		else:
			neg.append(item)
	currsum = -1
	b = []
	possum = sum(pos)
	negsum = sum(neg)
	if abs(possum) > abs(negsum):
		currsum = possum
		b = sorted(pos, reverse=True)
		countN = neg.count(-currsum)
		negnew = [item for item in neg if item != -currsum]
		negnew.sort(reverse=True)
		if len(negnew) < len(neg):
			negnew = negnew + countN * [-currsum]
		b = b + negnew
	else:
		currsum = negsum
		b = sorted(neg, reverse=True)
		countN = pos.count(-currsum)
		posnew = [item for item in pos if item != -currsum]
		posnew.sort()
		if len(posnew) < len(pos):
			posnew = posnew + countN * [-currsum]
		b = b + posnew
	b = b + countzero * [0]
	s = b[0]
	for h in range(1, n):
		if s == 0:
			flag = True
			break
		else:
			s += b[h]
	if s == 0:
		flag = True
	if flag:
		print('NO')
	else:
		print('YES')
		print(*b)
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	calc(n, a)


for _ in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	if sum(arr) == 0:
		ans = 'NO'
		print(ans)
	else:
		pos = 0
		neg = 0
		for item in arr:
			if item > 0:
				pos = pos + item
		for item in arr:
			if item < 0:
				neg = neg + item
		print('YES')
		if pos > abs(neg):
			arr.sort(reverse=True)
			s = 0
			a = []
			for item in arr:
				s = s + item
				if s == 0:
					a.append(item)
					s = s - item
					continue
				else:
					print(item, end=' ')
			for item in a:
				print(item, end=' ')
		else:
			arr.sort()
			s = 0
			a = []
			for item in arr:
				s = s + item
				if s == 0:
					a.append(item)
					s = s - item
					continue
				else:
					print(item, end=' ')
			for item in a:
				print(item, end=' ')
		print('')


for _ in range(int(input())):
	N = int(input())
	V = list(map(int, input().split()))
	s = sum(V)
	if s > 0:
		V.sort(reverse=True)
	else:
		V.sort()
	if s == 0:
		print('NO')
	else:
		print('YES')
		print(*V)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	su = sum(a)
	if su == 0:
		print('NO')
	elif su > 0:
		print('YES')
		print(*sorted(a, reverse=True))
	else:
		print('YES')
		print(*sorted(a))


tests = int(input())
while tests != 0:
	tests = tests - 1
	size = int(input())
	b = [int(x) for x in input().split()]
	sums = 0
	for i in b:
		sums = sums + i
	if sums == 0:
		print('NO')
		continue
	if sums > 0:
		b.sort(reverse=True)
		print('YES')
		for i in b:
			print(i, end=' ')
		print()
	elif sums < 0:
		b.sort()
		print('YES')
		for i in b:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sumi = sum(a)
	if sumi == 0:
		print('NO')
	else:
		neg = []
		pos = []
		z = []
		for i in range(n):
			if a[i] < 0:
				neg.append(a[i])
			elif a[i] == 0:
				z.append(a[i])
			else:
				pos.append(a[i])
		sumin = sum(neg)
		sumip = sum(pos)
		print('YES')
		if -sumin > sumip:
			print(*neg, *pos, *z)
		else:
			print(*pos, *neg, *z)


for _ in range(int(input())):
	a = int(input())
	arr = list(map(int, input().split()))
	b = 0
	c = ''
	sn = 0
	sp = 0
	for i in range(a):
		b += arr[i]
		if arr[i] > 0:
			sp += arr[i]
		elif arr[i] < 0:
			sn += abs(arr[i])
		if arr[i] == 0:
			c += ' 0'
	if sn > sp:
		ar = sorted(arr)
	elif sp > sn:
		ar = sorted(arr, reverse=True)
	if b != 0:
		print('YES\n')
		print(' '.join((str(x) for x in ar if x != 0)), end='')
		print(c)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	neg = [i for i in a if i < 0]
	pos = [i for i in a if i > 0]
	zero = [i for i in a if i == 0]
	if abs(sum(neg)) > sum(pos):
		ans = neg + pos + zero
	else:
		ans = pos + neg + zero
	if sum(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(*ans)


t = int(input())
while t != 0:
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	s = sum(arr)
	(pos, neg) = (0, 0)
	for i in arr:
		if i > 0:
			pos += i
		else:
			neg -= i
	if s == 0:
		print('NO')
	else:
		print('YES')
		if pos > neg:
			for i in arr:
				if i > 0:
					(print(i),)
			for i in arr:
				if i <= 0:
					(print(i),)
		else:
			for i in arr:
				if i < 0:
					(print(i),)
			for i in arr:
				if i >= 0:
					(print(i),)
		print
	t -= 1


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			print(' '.join(map(str, sorted(a)[::-1])))
		else:
			print(' '.join(map(str, sorted(a))))


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

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

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

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

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

def itg():
	return int(sys.stdin.readline())
from collections import Counter, defaultdict, deque
from itertools import accumulate

def solve():
	n = itg()
	ans = sorted(mpint(), reverse=True)
	if 0 in accumulate(ans):
		ans.reverse()
	if 0 not in accumulate(ans):
		print('YES')
		return ans
	return ['NO']
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
for _ in range(itg()):
	print(*solve())


from collections import Counter, OrderedDict
from itertools import permutations as perm
from sys import setrecursionlimit
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import threading
import math
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()
	val = sum(a)
	if val == 0:
		print('NO')
	else:
		print('YES')
		(neg, pos, z) = ([], [], 0)
		for v in a:
			if v == 0:
				z += 1
			elif v < 0:
				neg.append(v)
			else:
				pos.append(v)
		if val < 0:
			a.sort()
		else:
			a.sort(reverse=True)
		print(*a)


for tests in range(int(input())):
	a = int(input())
	b = [int(s) for s in input().split()]
	if sum(b) == 0:
		print('NO')
	else:
		pos = neg = zero = 0
		for i in range(len(b)):
			if b[i] > 0:
				pos += b[i]
			elif b[i] == 0:
				zero += 1
			else:
				neg -= b[i]
		e = []
		if pos > neg:
			for i in range(len(b)):
				if b[i] > 0:
					e.append(b[i])
			for i in range(zero):
				e.append(0)
			for i in range(len(b)):
				if b[i] < 0:
					e.append(b[i])
		if neg > pos:
			for i in range(len(b)):
				if b[i] < 0:
					e.append(b[i])
			for i in range(zero):
				e.append(0)
			for i in range(len(b)):
				if b[i] > 0:
					e.append(b[i])
		print('YES')
		for i in e:
			print(i, end=' ')
		print()


import sys
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	(pos, neg) = (0, 0)
	for x in arr:
		if x > 0:
			pos += x
		elif x < 0:
			neg += -1 * x
	if pos == neg:
		print('NO')
		continue
	print('YES')
	if pos > neg:
		arr.sort(reverse=True)
		for x in arr:
			print(x, end=' ')
		print()
	elif neg > pos:
		arr.sort()
		for x in arr:
			print(x, end=' ')
		print()


q = int(input())
for i in range(q):
	(y, u, t) = ([], [], [])
	w = int(input())
	x = [int(j) for j in input().split()]
	s = sum(x)
	if s == 0:
		print('NO')
	else:
		for j in x:
			if j > 0:
				y = y + [j]
			elif j < 0:
				u = u + [j]
			else:
				t = t + [j]
		if s > 0:
			s1 = y + u + t
		else:
			s1 = u + y + t
		print('YES')
		print(*s1)


for _ in range(int(input())):
	n = map(int, input().split())
	a = [*map(int, input().split())]
	pos = []
	neg = []
	z = []
	for i in a:
		if i < 0:
			neg.append(i)
		elif i > 0:
			pos.append(i)
		else:
			z.append(0)
	if len(z) == n:
		print('NO')
		continue
	elif sum(a) == 0:
		print('NO')
		continue
	print('YES')
	a = pos + neg if sum(pos) > -sum(neg) else neg + pos
	print(*a + z)


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')
import math
import bisect
from collections import Counter
import bisect
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		ne = []
		p = []
		z = []
		for i in range(n):
			if arr[i] > 0:
				p.append(arr[i])
			elif arr[i] == 0:
				z.append(0)
			else:
				ne.append(arr[i])
		if sum(p) > abs(sum(ne)):
			ans = p + ne + z
			print('YES')
			print(*ans)
		elif sum(p) < abs(sum(ne)):
			ans = ne + p + z
			print('YES')
			print(*ans)
		else:
			print('NO')


tests = int(input())
for test in range(tests):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) < 0:
		print('YES')
		print(' '.join((str(i) for i in sorted(a))))
	elif sum(a) > 0:
		print('YES')
		print(' '.join((str(i) for i in sorted(a)[::-1])))
	else:
		print('NO')


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import *
from math import *
for _ in range(int(read())):
	n = int(read())
	nums = sorted(readi())
	s = sum(nums)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		print(' '.join(map(str, nums[::-1])))
	else:
		print('YES')
		print(' '.join(map(str, nums)))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	sum = 0
	for i in A:
		sum += i
	A.sort()
	if sum == 0:
		print('NO')
	else:
		print('YES')
		if sum > 0:
			print(*A[::-1])
		else:
			print(*A)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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 binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(l) > 0:
			print(*l)
		else:
			print(*l[::-1])


import io
import os
import sys
import math
from typing import NamedTuple
from collections import deque
fileno = sys.stdin.fileno()
input = io.BytesIO(os.read(fileno, os.fstat(fileno).st_size)).readline
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	sum_positive = sum_negative = 0
	for a in A:
		if a > 0:
			sum_positive += a
		else:
			sum_negative += -a
	if sum_positive == sum_negative:
		print('NO')
		continue
	A.sort(reverse=sum_negative < sum_positive)
	print('YES')
	print(' '.join(map(str, A)))


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))[:b]
	c = [*c]
	neg = 0
	pos = 0
	total = 0
	for _ in c:
		total += _
		if _ > 0:
			pos += _
		else:
			neg += abs(_)
	if total == 0:
		print('NO')
	else:
		if pos > neg:
			c.sort(reverse=True)
		else:
			c.sort(reverse=False)
		print('YES')
		print(*c)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	_ = int(input())
	a = list(map(int, input().split()))
	temp = sum(a)
	a.sort(reverse=temp > 0)
	if temp == 0:
		print('NO')
	else:
		print('YES')
		print(*a)


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	c = 0
	for i in l:
		if i < 0:
			c += 1
		else:
			break
	if -sum(l[:c]) < sum(l[c:]):
		print('YES\n', *l[::-1])
	elif -sum(l[:c]) > sum(l[c:]):
		print('YES\n', *l)
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	ar = [int(i) for i in input().split()]
	if sum(ar) != 0:
		print('YES')
		if sum(ar) > 0:
			ar.sort(reverse=True)
		else:
			ar.sort()
		print(' '.join((str(i) for i in ar)))
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	if sum(A) == 0:
		print('NO')
	elif sum(A) > 0:
		B = []
		C = []
		Z = []
		for a in A:
			if a > 0:
				B.append(a)
			elif a < 0:
				C.append(a)
			else:
				Z.append(a)
		print('YES')
		print(*B + Z + C)
	else:
		B = []
		C = []
		Z = []
		for a in A:
			if a > 0:
				B.append(a)
			elif a < 0:
				C.append(a)
			else:
				Z.append(a)
		print('YES')
		print(*C + Z + B)


from sys import *
from math import *
from bisect import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = []
	rem = []
	s = 0
	for i in range(n):
		if a[i] > 0:
			b.append(a[i])
			s += a[i]
		else:
			rem.append(a[i])
	i = len(b)
	rem.sort()
	while i < n:
		x = -s
		f = 0
		for j in range(len(rem)):
			if x != rem[j]:
				b.append(rem[j])
				i += 1
				f = 1
				s += rem[j]
				rem.pop(j)
				break
		if f == 0:
			break
	if len(b) == n:
		print('YES')
		print(*b)
	else:
		b = []
		rem = []
		s = 0
		for i in range(n):
			if a[i] < 0:
				b.append(a[i])
				s += a[i]
			else:
				rem.append(a[i])
		i = len(b)
		rem.sort()
		rem = rem[::-1]
		while i < n:
			x = -s
			f = 0
			for j in range(len(rem)):
				if x != rem[j]:
					b.append(rem[j])
					i += 1
					f = 1
					s += rem[j]
					rem.pop(j)
					break
			if f == 0:
				break
		if len(b) == n:
			print('YES')
			print(*b)
		else:
			print('NO')


def solve(n, A):
	A.sort()
	cumsum = 0
	for a in A:
		cumsum += a
		if cumsum == 0:
			A.sort(reverse=True)
			break
	else:
		return A
	cumsum = 0
	for a in A:
		cumsum += a
		if cumsum == 0:
			return False
	else:
		return A

def test():
	pass

def main():
	T = int(input())
	for i in range(1, T + 1):
		n = int(input())
		A = [int(_) for _ in input().split(' ')]
		result = solve(n, A)
		if result:
			print('YES')
			print(' '.join([str(_) for _ in result]))
		else:
			print('NO')
main()


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = sorted(a)
	f1 = 0
	a2 = sorted(a, reverse=True)
	f2 = 0
	s1 = 0
	s2 = 0
	for i in a1:
		s1 += i
		if s1 == 0:
			f1 = 1
			break
	for i in a2:
		s2 += i
		if s2 == 0:
			f2 = 1
			break
	if f1 == 1 and f2 == 1:
		print('NO')
	else:
		print('YES')
		if f1 == 0:
			print(*a1)
		else:
			print(*a2)


from bisect import *
from math import *
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = LI()
	a.sort()
	b = []
	c = []
	s1 = 0
	s2 = 0
	for i in range(n):
		if a[i] > 0:
			b += [a[i]]
			s1 += a[i]
		else:
			c += [a[i]]
			s2 += a[i]
	if s1 + s2 != 0:
		print('YES')
		if abs(s2) > s1:
			print(*c, *b)
		else:
			print(*b, *c)
	else:
		print('NO')
for _ in range(I()):
	solve()


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
from sys import stdin, stdout
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')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def printEr(ar1):
	for i in range(len(ar1)):
		print(ar1[i], end=' ')
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	arZero = []
	arMoreZero = []
	arLessZero = []
	for i in range(n):
		if ar[i] < 0:
			arLessZero.append(ar[i])
		elif ar[i] > 0:
			arMoreZero.append(ar[i])
		else:
			arZero.append(ar[i])
	sumMoreZero = sum(arMoreZero)
	sumLessZero = abs(sum(arLessZero))
	if len(arZero) == n:
		print('NO')
	elif sumMoreZero == sumLessZero:
		print('NO')
	else:
		print('YES')
		if sumMoreZero > sumLessZero:
			printEr(arMoreZero)
			printEr(arLessZero)
			printEr(arZero)
		else:
			printEr(arLessZero)
			printEr(arMoreZero)
			printEr(arZero)
		print()


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

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

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

def spf():
	return map(int, input.readline().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 [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
for _ in range(int(input())):
	n = int(input())
	a = L()
	s = sum(a)
	if s != 0:
		print('YES')
		if s > 0:
			a = sorted(a, reverse=True)
			print(*a)
		else:
			a.sort()
			print(*a)
	else:
		print('NO')
endtime = time.time()


def avoiding_zero():
	prob = int(input())
	for _ in range(prob):
		l = int(input())
		ts = list(map(int, input().split()))
		sts = sum(ts)
		if sts == 0:
			print('NO')
		elif sts > 0:
			reorder = [v for v in ts if v > 0] + [v for v in ts if v == 0] + [v for v in ts if v < 0]
			print('YES')
			print(' '.join((str(v) for v in reorder)))
		elif sts < 0:
			reorder = [v for v in ts if v < 0] + [v for v in ts if v == 0] + [v for v in ts if v > 0]
			print('YES')
			print(' '.join((str(v) for v in reorder)))
avoiding_zero()


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	summ = sum(a)
	if summ == 0:
		print('NO')
		continue
	print('YES')
	b = sorted(a)
	if summ > 0:
		print(*b[::-1])
	else:
		print(*b)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if sum(ar) == 0:
		print('NO')
	else:
		su = sum(ar)
		pos = []
		neg = []
		zer = []
		for i in range(n):
			if ar[i] > 0:
				pos.append(ar[i])
			elif ar[i] == 0:
				zer.append(ar[i])
			else:
				neg.append(ar[i])
		if su > 0:
			print('YES')
			print(*pos + neg + zer)
		else:
			print('YES')
			print(*neg + pos + zer)


import os
import sys
from io import BytesIO, IOBase
import math

def numcat(a, b):
	return int(math.pow(10, int(math.log(b, 10)) + 1) * a + b)

def solution():
	n = int(input())
	a = list(map(int, input().split(' ')))
	val = sum(a)
	if val > 0:
		a.sort(reverse=True)
	elif val < 0:
		a.sort()
	else:
		print('NO')
		return
	print('YES')
	print(*a)
	return

def main():
	testcases = 1
	testcases = int(input())
	for _ in range(testcases):
		solution()
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')
main()


def solve(n, l):
	tot_sum = 0
	for i in range(n):
		tot_sum += l[i]
	if tot_sum == 0:
		return ['NO']
	elif tot_sum < 0:
		l.sort()
	else:
		l.sort(reverse=True)
	print('YES')
	return l
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(*solve(n, l))


def solve(n, a):
	s = 0
	cn = 0
	cp = 0
	for i in range(n):
		s += a[i]
		if a[i] > 0:
			cp += a[i]
		elif a[i] < 0:
			cn += a[i]
	if s != 0:
		print('YES')
		if cp > abs(cn):
			a.sort(reverse=True)
		elif abs(cn) > cp:
			a.sort(reverse=False)
		print(*a, sep=' ')
	else:
		print('NO')
noOfTestCases = int(input())
for i in range(noOfTestCases):
	n = int(input())
	a = list(map(int, input().split()))
	solve(n, a)


def solve(n, a):
	summ = sum(a)
	if summ == 0:
		print('NO')
	else:
		print('YES')
		if summ > 0:
			a = sorted(a, reverse=True)
		else:
			a = sorted(a)
		for (index, x) in enumerate(a):
			if index == len(a) - 1:
				print(x)
			else:
				print(x, end=' ')
t = int(input())
for i in range(t):
	n = input()
	a = list(map(int, input().split()))
	solve(n, a)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		L = [int(x) for x in input().split()]
		solver(L)

def solver(L):
	positives = [x for x in L if x > 0]
	negatives = [x for x in L if x < 0]
	zeroes = [x for x in L if x == 0]
	if sum(positives) > -sum(negatives):
		print('YES')
		result = positives + negatives + zeroes
		printList(result)
	elif sum(positives) < -sum(negatives):
		print('YES')
		result = negatives + positives + zeroes
		printList(result)
	else:
		print('NO')

def printList(L):
	for item in L:
		print(item, end=' ')
	print()
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	if sum(a) > 0:
		for i in sorted(a, reverse=True):
			print(i, end=' ')
	else:
		for i in sorted(a):
			print(i, end=' ')
	print()


def all_perms(elements):
	if len(elements) <= 1:
		yield elements
	else:
		for perm in all_perms(elements[1:]):
			for i in range(len(elements)):
				yield (perm[:i] + elements[0:1] + perm[i:])
tests_no = int(input())
for _ in range(tests_no):
	n = int(input())
	a = list(map(int, input().split()))
	whole_sum = sum(a)
	if whole_sum == 0:
		print('NO')
	elif whole_sum < 0:
		ri = n - 1
		li = 0
		b = [0] * n
		for i in range(n):
			if a[i] >= 0:
				b[ri] = a[i]
				ri -= 1
			else:
				b[li] = a[i]
				li += 1
		print('YES')
		print(*b)
	else:
		ri = n - 1
		li = 0
		b = [0] * n
		for i in range(n):
			if a[i] <= 0:
				b[ri] = a[i]
				ri -= 1
			else:
				b[li] = a[i]
				li += 1
		print('YES')
		print(*b)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = sorted(R())
	p = sum(a)
	if p == 0:
		print('NO')
	else:
		print('YES')
		if p > 0:
			print(*a[::-1])
		else:
			print(*a)


import sys
import math

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

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

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

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		x = []
		y = []
		count = 0
		for i in a:
			if i > 0:
				x.append(i)
			elif i < 0:
				y.append(i)
			else:
				count += 1
		s = sum(x)
		s1 = abs(sum(y))
		if s > s1:
			a = x + y + [0] * count
		else:
			a = y + x + [0] * count
		print(*a)


t = int(input())
for i in range(t):
	res = 0
	n = int(input())
	lst = list(map(int, input().split(' ')[:n]))
	if sum(lst) > 0:
		print('Yes')
		lst.sort()
		lst.reverse()
		for k in lst:
			print(k, end=' ')
		print()
	elif sum(lst) < 0:
		print('Yes')
		lst.sort()
		for k in lst:
			print(k, end=' ')
		print()
	else:
		print('No')


for case in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	sm = sum(arr)
	zero = 0
	(neg, pos) = ([], [])
	for it in arr:
		if it < 0:
			neg.append(it)
		else:
			pos.append(it)
	pos.sort(reverse=True)
	neg.sort(reverse=True)
	if sm == 0:
		print('NO')
	elif sm < 0:
		print('YES')
		li = neg + pos
		print(*li)
	else:
		print('YES')
		li = pos + neg
		print(*li)


from sys import stdin, stdout
from collections import Counter
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
INF = float('inf')

def solve():
	n = inp()
	l = li()
	s = sum(l)
	if s == 0:
		pr('NO')
		return
	pr('YES')
	l = sorted(l)
	a = 0
	for i in l:
		a += i
		if a == 0:
			print(*l[::-1])
			return
	print(*l)
for _ in range(inp()):
	solve()


import sys as snus
t = int(snus.stdin.readline())
for _ in range(t):
	n = int(snus.stdin.readline())
	a = list(map(int, snus.stdin.readline().split()))
	b = sum(a)
	if b == 0:
		print('NO')
		continue
	elif b > 0:
		c = a.copy()
		c.sort(reverse=True)
	else:
		c = a.copy()
		c.sort()
	print('YES')
	print(*c)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	total = 0
	l = 0
	r = 0
	for i in range(n):
		if a[i] >= 0:
			r += a[i]
		else:
			l += a[i] * -1
		total += a[i]
	a.sort()
	if total == 0:
		print('NO')
	else:
		print('YES')
		if r > l:
			print(' '.join(map(str, a[::-1])))
		else:
			print(' '.join(map(str, a)))
	t -= 1


import sys
import bisect as bi
import collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	n = I()
	l = I()
	s = sum(l)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		l.sort(reverse=True)
		print(*l)
	else:
		print('YES')
		l.sort()
		print(*l)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	negs = 0
	poss = 0
	for i in arr:
		if i < 0:
			negs += i
		else:
			poss += i
	if abs(negs) == poss:
		print('NO')
	elif sum(arr) > 0:
		print('YES')
		arr.sort(reverse=True)
		print(*arr)
	else:
		print('YES')
		arr.sort()
		print(*arr)
	t -= 1


import sys as _sys

def main():
	t = int(input())
	for i_t in range(t):
		(n,) = _read_ints()
		a = tuple(_read_ints())
		try:
			result = find_b_array(a)
		except ValueError:
			print('NO')
		else:
			print('YES')
			print(*result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split())

def find_b_array(a_array):
	if len(a_array) == 0:
		return []
	if sum(a_array) == 0:
		raise ValueError("can't compose b_array because a_array sum equals zero")
	positive_elements = [x for x in a_array if x > 0]
	negative_elements = [x for x in a_array if x < 0]
	zero_elements = [x for x in a_array if x == 0]
	if abs(sum(positive_elements)) > abs(sum(negative_elements)):
		b_array = positive_elements + negative_elements + zero_elements
	else:
		b_array = negative_elements + positive_elements + zero_elements
	return b_array
main()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sum(a)
	a.sort()
	if b == 0:
		print('NO')
	elif b > 0:
		print('YES')
		print(' '.join(map(str, a[::-1])))
	else:
		print('YES')
		print(' '.join(map(str, a)))


import sys
input = sys.stdin.readline

def main():
	T = int(input())
	for t in range(T):
		n = int(input())
		a = list(map(int, input().split()))
		s = sum(a)
		if s == 0:
			print('NO')
		else:
			print('YES')
			print(*sorted(a, reverse=s > 0))
main()


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
from itertools import permutations
MOD = pow(10, 9) + 7
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')
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	a = sum(l)
	if a == 0:
		print('NO')
	elif a > 0:
		print('YES')
		print(*sorted(l, reverse=True))
	else:
		print('YES')
		print(*sorted(l))


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	if sum(ar) == 0:
		print('NO')
	elif sum(ar) < 0:
		print('YES')
		ar = sorted(ar)
		print(*ar)
	elif sum(ar) > 0:
		print('YES')
		ar = sorted(ar, reverse=True)
		print(*ar)


import sys
from collections import defaultdict as dc
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		p = []
		q = []
		z = []
		for i in l:
			if i > 0:
				p.append(i)
			elif i < 0:
				q.append(i)
			else:
				z.append(i)
		p.sort(reverse=True)
		q.sort()
		if abs(sum(p)) > abs(sum(q)):
			x = p + q + z
		else:
			x = q + p + z
		print(*x)


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n4\n1 -2 3 -4\n3\n0 0 0\n5\n1 -1 1 -1 1\n6\n40 -31 -9 0 13 -40\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def tuplerize(method):

	def wrap(*args, **kwargs):
		res = method(*args, **kwargs)
		if not isinstance(res, (tuple, list)):
			res = (res,)
		return res
	return wrap

def binary_pow(a, b):
	result = 1
	while b:
		if b % 1:
			result *= a
		a *= a
		b >>= 1
	return result

@tuplerize
def solve(a):
	pos = []
	neg = []
	zeros = []
	for x in a:
		if x > 0:
			pos.append(x)
		elif x < 0:
			neg.append(-x)
		else:
			zeros.append(x)
	if sum(pos) == sum(neg):
		return 'NO'
	(first, second) = (pos, neg)
	if sum(pos) > sum(neg):
		return ('YES', ' '.join([str(y) for y in pos + [-x for x in neg] + zeros]))
	else:
		return ('YES', ' '.join([str(y) for y in [-x for x in neg] + pos + zeros]))
t = getType(int)
for _ in range(t):
	n = getType(int)
	a = getArray(int)
	res = solve(a)
	if res[0] == 'NO':
		print('NO')
	else:
		print('YES')
		print(res[1])


import random

def result(array):
	if sum(array) == 0:
		return 'NO'
	test = False
	while not test:
		random.shuffle(array)
		if verif(array, a):
			test = True
			print('Yes')
			x = ''
			for num in array:
				x += str(num) + ' '
			return x
			break
		else:
			continue
	if not test:
		return 'NO'

def verif(array, a):
	if array[0] == 0:
		return False
	else:
		sum = array[0]
		compt = 1
		while sum != 0 and compt < a:
			sum += array[compt]
			compt += 1
		if compt == a:
			return True
		else:
			return False
testCases = int(input())
for i in range(testCases):
	a = int(input())
	array = list(map(int, input().split()))
	print(result(array))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pos = neg = 0
	positive = []
	negative = []
	for i in range(n):
		if l[i] < 0:
			neg += l[i]
			negative.append(l[i])
		else:
			pos += l[i]
			positive.append(l[i])
	if pos == -1 * neg:
		print('NO')
	elif -1 * neg > pos:
		print('YES')
		print(*negative, end=' ')
		print(*positive)
	else:
		print('YES')
		positive.sort(reverse=True)
		print(*positive, end=' ')
		print(*negative)


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')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

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

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	b = sorted([k for k in a if k != 0], reverse=True)
	b2 = sorted([k for k in a if k])
	c = [k for k in a if k == 0]
	t = 0
	for i in b:
		t += i
		if t == 0:
			b = list(b2)
			break
	print(*b + c)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = n = c = 0
	for i in l:
		if i > 0:
			p += i
		elif i < 0:
			n += i
		else:
			c += 1
	n = -n
	if p == n:
		print('NO')
	else:
		print('YES')
		if p > n:
			for i in l:
				if i > 0:
					print(i, end=' ')
			for i in l:
				if i < 0:
					print(i, end=' ')
		else:
			for i in l:
				if i < 0:
					print(i, end=' ')
			for i in l:
				if i > 0:
					print(i, end=' ')
		for i in range(c):
			print(0, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	w = [int(k) for k in input().split()]
	c = sum(w)
	(a, b) = ([], [])
	if c > 0:
		for j in w:
			if j > 0:
				a.append(j)
			else:
				b.append(j)
	elif c == 0:
		print('NO')
		continue
	else:
		for j in w:
			if j < 0:
				a.append(j)
			else:
				b.append(j)
	print('YES')
	print(' '.join([str(k) for k in a + b]))


for _ in range(int(input())):
	t = int(input())
	a = list(map(int, input().split()))
	n = []
	z = []
	p = []
	for i in a:
		if i < 0:
			n.append(i)
		elif i == 0:
			z.append(i)
		elif i > 0:
			p.append(i)
	if abs(sum(n)) > abs(sum(p)):
		tt = n + p + z
		print('YES')
		print(*tt)
	elif abs(sum(n)) == abs(sum(p)):
		print('NO')
	elif abs(sum(n)) < abs(sum(p)):
		print('YES')
		tt = p + z + n
		print(*tt)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	ne = []
	po = []
	z = []
	for i in range(n):
		if a[i] < 0:
			ne.append(a[i])
		elif a[i] > 0:
			po.append(a[i])
		else:
			z.append(a[i])
	ns = 0
	ps = 0
	if len(ne) > 0:
		ns = sum(ne)
	if len(po) > 0:
		ps = sum(po)
	if ns + ps == 0:
		print('NO')
	elif ns + ps < 0:
		print('YES')
		print(*ne, *po, *z)
	else:
		print('YES')
		print(*po, *ne, *z)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	n = inn()
	a = arr()
	if sum(a) == 0:
		print('NO')
	else:
		sp = 0
		sn = 0
		c = 0
		for i in a:
			if i < 0:
				sn += abs(i)
			elif i > 0:
				sp += i
			else:
				c += 1
		ans = []
		if sp > sn:
			for i in a:
				if i > 0:
					ans += [i]
			ans += [0] * c
			for i in a:
				if i < 0:
					ans += [i]
		else:
			for i in a:
				if i < 0:
					ans += [i]
			ans += [0] * c
			for i in a:
				if i > 0:
					ans += [i]
		print('YES')
		print(*ans)


from itertools import permutations
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
		continue
	elif sum(arr) > 0:
		arr.sort(reverse=True)
		print('YES')
		print(*arr)
	else:
		print('YES')
		arr.sort()
		print(*arr)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

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

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		s = sum(a)
		if s == 0:
			print('NO')
			continue
		a.sort(reverse=True)
		f = 0
		s = 0
		for i in range(n):
			s += a[i]
			if s == 0:
				f = 1
				break
		if f == 0:
			print('YES')
			print(*a)
		else:
			f = 0
			a.reverse()
			s = 0
			for i in range(n):
				s += a[i]
				if s == 0:
					f = 1
					break
			if f == 0:
				print('YES')
				print(*a)
			else:
				print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = [''] * t
	for ti in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		(positive, negative) = (sum((x for x in a if x > 0)), sum((-x for x in a if x < 0)))
		if positive == negative:
			ans_a[ti] = 'NO'
		elif positive > negative:
			ans_a[ti] = 'YES\n' + ' '.join(map(str, sorted(a, reverse=True)))
		else:
			ans_a[ti] = 'YES\n' + ' '.join(map(str, sorted(a)))
	output(*ans_a)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(p1, p2) = ([i for i in l if i >= 0], [i for i in l if i < 0])
	p1.sort(reverse=True)
	(s1, s2) = (sum(p1), sum(p2))
	if s1 > -s2:
		print('YES')
		r = p1[:] + p2[:]
		print(*r)
	elif -s2 > s1:
		print('YES')
		r = p2[:] + p1[:]
		print(*r)
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	one = []
	two = []
	zero = []
	for i in a:
		if i > 0:
			one.append(i)
		elif i < 0:
			two.append(i)
		else:
			zero.append(i)
	if sum(one) > abs(sum(two)):
		one = one + two
	else:
		one = two + one
	one = one + zero
	print(*one)


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	counter = 0
	for each_item in a:
		counter += each_item
	if counter > 0:
		print('YES')
		result = sorted(a, key=None, reverse=True)
		string = ''
		for e in result:
			string += str(e) + ' '
		print(string)
	elif counter < 0:
		print('YES')
		result = sorted(a)
		string = ''
		for e in result:
			string += str(e) + ' '
		print(string)
	else:
		print('NO')


import sys
nextline = sys.stdin.readline
tests = int(nextline())
for test in range(tests):
	n = int(nextline())
	a = [int(x) for x in nextline().split()]
	s = sum(a)
	if s == 0:
		print('NO')
		continue
	a.sort()
	if s > 0:
		a.reverse()
	print('YES')
	for i in a:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	pos = []
	neg = []
	(pp, nn) = (0, 0)
	for i in range(n):
		if l[i] >= 0:
			pos.append(l[i])
			pp += l[i]
		else:
			neg.append(l[i])
			nn += l[i]
	if pp + nn == 0:
		print('NO')
	else:
		print('YES')
		if pp + nn > 0:
			print(*pos, *neg)
		else:
			print(*neg, *pos)


t = int(input())
for i in range(t):
	n = int(input())
	lst = [int(s) for s in input().split()]
	lst_sorted = sorted(lst)
	if sum(lst) == 0:
		print('NO')
	else:
		if sum(lst_sorted) > 0:
			lst_sorted.reverse()
		print('YES')
		print(*lst_sorted)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	total = sum(alst)
	if total == 0:
		print('NO')
		return
	print('YES')
	alst.sort()
	if total > 0:
		print(*alst[::-1])
	else:
		print(*alst)
for _ in range(int(input())):
	main()


import sys
t = int(sys.stdin.readline())
for i in range(0, t):
	tamt = sys.stdin.readline()
	vall = sys.stdin.readline().split()
	for i in range(0, len(vall)):
		vall[i] = int(vall[i])
	vall.sort()
	TEMP = []
	for K in vall:
		TEMP.append(K)
	s = 0
	t = ''
	while len(vall) > 0:
		if s + vall[0] != 0:
			s += vall[0]
			t += str(vall[0])
			vall.pop(0)
		else:
			s += vall[len(vall) - 1]
			t += str(vall[len(vall) - 1])
			vall.pop(len(vall) - 1)
		t += ' '
		if s == 0:
			break
	if s == 0:
		TEMP.sort(reverse=True)
		s = 0
		t = ''
		while len(TEMP) > 0:
			if s + TEMP[0] != 0:
				s += TEMP[0]
				t += str(TEMP[0])
				TEMP.pop(0)
			else:
				s += TEMP[len(vall) - 1]
				t += str(TEMP[len(vall) - 1])
				TEMP.pop(len(vall) - 1)
			t += ' '
			if s == 0:
				break
		if s == 0:
			sys.stdout.write('NO\n')
		else:
			sys.stdout.write('YES\n')
			sys.stdout.write(t + '\n')
	else:
		sys.stdout.write('YES\n')
		sys.stdout.write(t + '\n')


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = [i for i in a if i > 0]
	neg = [i for i in a if i < 0]
	zero = [i for i in a if i == 0]
	spos = sum(pos)
	sneg = -sum(neg)
	if spos == sneg:
		print('NO')
		continue
	if spos < sneg:
		(pos, neg) = (neg, pos)
	print('YES')
	ans = map(str, pos + neg + zero)
	print(' '.join(ans))


import sys, math
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = sum(l)
	if ans == 0:
		print('NO')
	else:
		print('YES')
		if ans > 0:
			l.sort(reverse=True)
		else:
			l.sort()
		for i in l:
			print(i, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list((int(n) for n in input().split()))
	list2 = list1[:]
	list1.sort(reverse=True)
	list2.sort()
	flag1 = 0
	total = 0
	flag2 = 0
	for i in range(n):
		total += list1[i]
		if total == 0:
			flag1 = 1
			break
	total1 = 0
	for i in range(n):
		total1 += list2[i]
		if total1 == 0:
			flag2 = 1
			break
	if flag1 == 1 and flag2 == 1:
		print('NO')
	else:
		print('YES')
		if flag1 != 1:
			print(*list1)
		else:
			print(*list2)


for i in range(int(input())):
	n = int(input())
	for j in range(n - (n - 1)):
		x = list(map(int, input().split()))
	x.sort()
	if sum(x) == 0:
		print('NO')
		continue
	s = 0
	for i in x:
		s = s + i
		if s == 0:
			x.sort(reverse=True)
	print('YES')
	print(' '.join(map(str, x)))


def examA():
	T = I()
	ans = []
	for _ in range(T):
		N = I()
		B = LI()
		if sum(B) == 0:
			print('NO')
			continue
		print('YES')
		B.sort()
		for i in range(N):
			cur = []
			now = 0
			for j in range(N):
				now += B[i - j]
				if now == 0:
					break
				cur.append(B[i - j])
			if len(cur) == N:
				print(' '.join(map(str, cur)))
				break
	return

def examB():
	T = I()
	ans = []
	for _ in range(T):
		cur = 0
		ans.append(cur)
	for v in ans:
		print(v)
	return

def examC():
	T = I()
	ans = []
	for _ in range(T):
		cur = 0
		ans.append(cur)
	for v in ans:
		print(v)
	return

def examD():
	ans = 0
	print(ans)
	return

def examE():
	ans = 0
	print(ans)
	return

def examF():
	ans = 0
	print(ans)
	return
from decimal import getcontext, Decimal as dec
import sys, bisect, heapq
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

def DI():
	return dec(input())

def LDI():
	return list(map(dec, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

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

def SI():
	return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
_ep = dec('0.000000000001')
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}
getcontext().prec = 28
sys.setrecursionlimit(2 * 10 ** 5)
examA()


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	(chk1, chk2) = (True, True)
	(s1, s2) = (0, 0)
	for i in range(n):
		s1 += l[i]
		s2 += l[n - 1 - i]
		if s1 == 0:
			chk1 = False
		if s2 == 0:
			chk2 = False
	if chk1:
		print('YES')
		print(*l)
	elif chk2:
		print('YES')
		print(*l[::-1])
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	if sum(li) == 0:
		print('NO')
	else:
		pos = 0
		for i in li:
			if i > 0:
				pos += i
		neg = abs(sum(li) - pos)
		print('YES')
		if neg > pos:
			li.sort()
			print(*li)
		else:
			li.sort()
			li.reverse()
			print(*li)


for _ in range(int(input())):
	n = int(input())
	la = list(map(int, input().split()))
	a = la
	p = sorted([i for i in la if i > 0], reverse=True)
	p_siz = len(p)
	neg = sorted([i for i in la if i <= 0])
	n_siz = len(neg)
	if sum(a) == 0:
		print('NO')
		continue
	flag = False
	if sum(p) > abs(sum(neg)):
		if sum(p) != 0:
			ans = p
			sm = sum(p)
			k = len(p)
			flag = True
		elif sum(neg) != 0:
			ans = neg
			sm = sum(neg)
			k = len(neg)
	else:
		ans = neg
		sm = sum(neg)
		k = len(neg)
	for i in range(n):
		j = 0
		if flag:
			a = neg
		else:
			a = p
		sz = len(a)
		while j < sz:
			if sm + a[j] != 0:
				ans.append(a[j])
				sm += a[j]
				a.remove(a[j])
				break
			else:
				j += 1
	if len(ans) == n:
		print('YES')
		print(*ans)
	else:
		print('NO')


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	sa = sum(a)
	if sa == 0:
		print('NO')
	elif sa > 0:
		print('YES')
		print(*sorted(a, reverse=True))
	else:
		print('YES')
		print(*sorted(a))


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	total = sum(a)
	ans = False
	if total != 0:
		ans = True
	if total > 0:
		a.sort(reverse=True)
	if total < 0:
		a.sort()
	if ans:
		print('YES')
		for e in a:
			print(e, end=' ')
		print()
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	p = []
	ne = []
	z = []
	for j in range(n):
		if a[j] > 0:
			p.append(a[j])
		elif a[j] < 0:
			ne.append(a[j])
		else:
			z.append(a[j])
	print('YES')
	if sum(p) > abs(sum(ne)):
		print(' '.join(map(str, p + ne + z)))
	else:
		print(' '.join(map(str, ne + p + z)))


T = int(input())
res = []
for t in range(T):
	n = int(input())
	a = [int(k) for k in input().split()]
	if sum(a) == 0:
		res.append('NO')
	elif sum(a) > 0:
		a.sort(reverse=True)
		res.append(a)
	else:
		a.sort()
		res.append(a)
for i in res:
	if i == 'NO':
		print('NO')
	else:
		print('YES', sep=' ')
		for j in i:
			print(j, end=' ')
		print(sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) > 0:
		a.sort(reverse=True)
	else:
		a.sort()
	s = 0
	bad = False
	for i in range(n):
		s += a[i]
		if s == 0:
			m = i
			bad = True
			break
	if bad:
		if a[-1] == a[m]:
			res = False
		else:
			res = True
			b = []
			for i in range(m):
				b.append(a[i])
			b.append(a[-1])
			for i in range(m, n - 1):
				b.append(a[i])
	else:
		res = True
		b = a
	if res:
		print('YES')
		for x in b:
			print(x, end=' ')
		print()
	else:
		print('NO')


import sys

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
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	a = ria()
	(p, n) = ([], [])
	sp = 0
	sn = 0
	if sum(a) == 0:
		ws('NO')
	else:
		ws('YES')
		for i in a:
			if i >= 0:
				sp += i
				p.append(i)
			else:
				sn += i
				n.append(i)
		ans = []
		if sp > abs(sn):
			p.sort(reverse=1)
			n.sort()
			ans = p + n
		else:
			ans = n + p
			p.sort()
			n.sort(reverse=1)
		wia(ans)


import sys
T = int(sys.stdin.readline())
for t in range(0, T):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().strip().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if sum(a) > 0:
			a.reverse()
		print(' '.join(list(map(str, a))))


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict

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

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

def Neo():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	A = Neo()
	A.sort()
	if sum(A) == 0:
		print('NO')
	elif sum(A) > 0:
		print('YES')
		print(*A[::-1])
	else:
		print('YES')
		print(*A)


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def chek(m):
	ans = 0
	for i in m:
		ans += i
		if ans == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)[::-1]
	if chek(a):
		print('YES')
		print(*a)
	else:
		a = a[::-1]
		if chek(a):
			print('YES')
			print(*a)
		else:
			print('NO')


import os
import sys
from io import BytesIO, IOBase
import math
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')
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ps = list()
	l.sort()
	s = 0
	ss = 0
	f = True
	for i in range(n):
		s += l[i]
		if s == 0:
			f = False
			break
	if f:
		print('YES')
		print(*l, end=' ')
		print()
	else:
		ff = True
		l.sort(reverse=True)
		for i in range(n):
			ss += l[i]
			if ss == 0:
				ff = False
				break
		if ff:
			print('YES')
			print(*l, end=' ')
			print()
		else:
			print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		if s > 0:
			a.reverse()
		for k in a:
			print(k, end=' ')
		print()


from typing import List
import sys
reader = sys.stdin.readline
num_tests = int(reader().strip())
answers = [None] * num_tests
for i in range(num_tests):
	reader()
	arr = [int(x) for x in reader().strip().split(' ')]
	arr_sum = 0
	for num in arr:
		arr_sum += num
	if arr_sum == 0:
		answers[i] = (False, [])
		continue
	elif arr_sum > 0:
		arr = sorted(arr, reverse=True)
	else:
		arr.sort()
	answers[i] = (True, arr)
for answer in answers:
	if not answer[0]:
		print('NO')
	else:
		print('YES')
		print(' '.join([str(x) for x in answer[1]]))


a = input()
for i in range(int(a)):
	input()
	b = input().split(' ')
	for i in range(len(b)):
		b[i] = int(b[i])
	if sum(b) == 0:
		print('NO')
	elif sum(b) < 0:
		print('YES')
		c = []
		for i in b:
			if i < 0:
				c.append(str(i))
		for i in b:
			if i >= 0:
				c.append(str(i))
		print(' '.join(c))
	else:
		print('YES')
		c = []
		for i in b:
			if i > 0:
				c.append(str(i))
		for i in b:
			if i <= 0:
				c.append(str(i))
		print(' '.join(c))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	b = []
	c = []
	for i in a:
		if i <= 0:
			b.append(i)
		else:
			c.append(i)
	b = sorted(b)
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if abs(sum(b)) > sum(c):
			print(*b, end=' ')
			print(*c)
		else:
			print(*c, end=' ')
			print(*b)


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	s = sum(a)
	if s == 0:
		print('NO')
	elif s < 0:
		res = ''
		a = sorted(a)
		for i in a:
			res = res + str(i) + ' '
		print('YES')
		print(res)
	elif s > 0:
		res = ''
		a = sorted(a, reverse=True)
		for i in a:
			res = res + ' ' + str(i)
		print('YES')
		print(res)


import sys
t = int(input())
for tc in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	s = sum(lst)
	if s == 0:
		print('no')
		continue
	lst.sort()
	print('yes')
	if s > 0:
		for i in range(n - 1, -1, -1):
			print(lst[i], end=' ')
	else:
		for i in lst:
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	A = [int(m) for m in input().split()]
	s = sum(A)
	if s == 0:
		print('NO')
	else:
		if s > 0:
			A.sort(reverse=True)
		else:
			A.sort()
		print('Yes')
		print(' '.join((str(n) for n in A)))


for t in range(int(input())):
	n = int(input())
	d = [int(i) for i in input().split()]
	d.sort()
	if sum(d) == 0:
		print('NO')
	else:
		print('YES')
		if sum(d) > 0:
			d.reverse()
		print(*d)


import math
import os
import random
import re
import sys

def avoidZero(l, arr):
	sum = 0
	for a in arr:
		sum += a
	if sum == 0:
		print('NO')
	else:
		arr = sorted(arr)
		if sum > 0:
			arr = reversed(arr)
		print('YES')
		print(' '.join(map(str, arr)))
n = int(input())
for i in range(n):
	l = int(input())
	arr = list(map(int, input().rstrip().split()))
	avoidZero(l, arr)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort()
	if sum(arr) == 0:
		print('NO')
	elif sum(arr) > 0:
		print('YES')
		print(*arr[::-1])
	else:
		print('YES')
		print(*arr)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
for _ in range(II()):
	n = II()
	aa = LI()
	pp = []
	mm = []
	z = 0
	for a in aa:
		if a > 0:
			pp.append(a)
		elif a < 0:
			mm.append(a)
		else:
			z += 1
	sp = sum(pp)
	sm = sum(mm)
	if sp == -sm:
		print('NO')
		continue
	if sp > -sm:
		ans = pp + mm + [0] * z
	else:
		ans = mm + pp + [0] * z
	print('YES')
	print(*ans)


import random

def swap(arr, arg1, arg2):
	temp = arr[arg1]
	arr[arg1] = arr[arg2]
	arr[arg2] = temp
for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		falg = False
		i = 0
		curr_sum = 0
		while i < n - 1:
			if curr_sum + arr[i] == 0:
				j = i + 1
				while j < n:
					swap(arr, i, j)
					temp = curr_sum + arr[i]
					if temp != 0:
						break
					else:
						swap(arr, i, j)
						j += 1
				if j == n:
					curr_sum = 0
					i = 0
					random.shuffle(arr)
			else:
				curr_sum += arr[i]
				i += 1
		if falg == True:
			print('NO')
		else:
			print('YES')
			for i in arr:
				print(i, end=' ')
			print()


for i in range(int(input())):
	n = int(input())
	s = [int(j) for j in input().split()]
	s1 = 0
	for j in s:
		s1 += j
	if s1 == 0:
		print('NO')
	else:
		print('YES')
		s.sort(reverse=True)
		s3 = 0
		s4 = 0
		for j in s:
			if j < 0:
				s3 = s3 + j
			else:
				s4 = s4 + j
		s3 = -s3
		if s4 < s3:
			s.sort()
		for j in s:
			print(j, end=' ')
		print()


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

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

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
for tt in range(INT()):
	n = INT()
	arr = LIST()
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		if sum(arr) > 0:
			arr.sort(reverse=True)
			print(*arr)
		else:
			arr.sort()
			print(*arr)


from sys import stdin, stdout
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	lst = []
	lst = [int(x) for x in stdin.readline().split()]
	sum = 0
	for i in range(0, n):
		sum += lst[i]
	if sum == 0:
		print('NO')
		continue
	print('YES')
	if sum < 0:
		lst.sort()
		for i in range(0, n):
			print(lst[i], end=' ')
		print()
		continue
	if sum > 0:
		lst.sort(reverse=True)
		for i in range(0, n):
			print(lst[i], end=' ')
		print()
		continue


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join([str(i) for i in a]) + end)

def check(a):
	s = 0
	x = 0
	for i in a:
		s += i
		if s == 0:
			return x
		else:
			x += 1
	return x

def solve(a, n):
	if sum(a) == 0:
		put('NO')
		return 0
	a = sorted(a)
	x = check(a)
	cnt = 0
	while x != n:
		if cnt >= n:
			break
		for y in range(x, n):
			if a[y] != a[x]:
				(a[y], a[x]) = (a[x], a[y])
				break
		cnt += 1
		x = check(a)
	if check(a) != n:
		a = sorted(a, reverse=True)
		x = check(a)
		while x != n:
			if cnt >= n:
				break
			for y in range(x, n):
				if a[y] != a[x]:
					(a[y], a[x]) = (a[x], a[y])
					break
			x = check(a)
	put('YES')
	putf(a)

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


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort(reverse=True)
	su = 0
	np = False
	for x in ar:
		su += x
		if su == 0:
			np = True
	if np:
		ar.sort()
		su = 0
		np = False
		for x in ar:
			su += x
			if su == 0:
				np = True
		if np:
			print('NO')
		else:
			print('YES')
			print(*ar)
	else:
		print('YES')
		print(*ar)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

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

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

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

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

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def fn(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n //= 2
	return c

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		l = []
		l1 = []
		l2 = []
		for i in range(n):
			if a[i] == 0:
				l2.append(a[i])
			elif a[i] > 0:
				l.append(a[i])
			else:
				l1.append(a[i])
		s1 = sum(l)
		s2 = abs(sum(l1))
		if s1 == s2:
			print('NO')
		else:
			ans = []
			if s1 > s2:
				ans.extend(l)
				ans.extend(l1)
				ans.extend(l2)
			else:
				ans.extend(l1)
				ans.extend(l)
				ans.extend(l2)
			print('YES')
			print(*ans)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


test = int(input())
for i in range(test):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	temp1 = sorted(a, reverse=True)
	temp = sorted(a)
	s = 0
	flag = 0
	flag1 = 0
	for i in temp:
		s += i
		if s == 0:
			flag = 1
			break
	s = 0
	for i in temp1:
		s += i
		if s == 0:
			flag1 = 1
			break
	if flag == 1 and flag1 == 1:
		print('NO')
	elif flag == 0:
		print('YES')
		print(*temp)
	elif flag1 == 0:
		print('YES')
		print(*temp1)


test_cases = int(input())
for t in range(test_cases):
	n = int(input())
	nums = list(map(int, input().split()))
	list_sum = sum(nums)
	if list_sum == 0:
		print('NO')
	else:
		print('YES')
		if list_sum > 0:
			print(' '.join(list(map(str, sorted(nums, reverse=True)))))
		else:
			print(' '.join(list(map(str, sorted(nums)))))


import sys
import math

def scan(input_type='int'):
	return list(map(int, sys.stdin.readline().strip().split()))

def solution():
	for _ in range(int(input())):
		n = int(input())
		a = scan()
		s = sum(a)
		if s == 0:
			print('NO')
		else:
			print('YES')
			if s > 0:
				a.sort()
				a.reverse()
			elif s < 0:
				a.sort()
			for i in a:
				print(i, end=' ')
			print()
solution()


for test in range(0, int(input())):
	n = int(input())
	x = [int(f) for f in input().split()]
	if sum(x) == 0:
		print('NO')
		continue
	elif sum(x) > 0:
		x.sort(reverse=True)
	else:
		x.sort()
	print('YES')
	for i in x:
		print(i, end=' ')
	print('')
	continue


import sys
import math
from math import *
from collections import Counter, defaultdict, deque
from bisect import bisect_left
import random
lip = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input().split()
mod = 10 ** 9 + 7

def check(arr):
	sum = 0
	for i in arr:
		sum += i
		if sum == 0:
			return False
	return True

def main():
	n = ip()
	arr = lip()
	if sum(arr) == 0:
		print('NO')
		return
	print('YES')
	while True:
		random.shuffle(arr)
		if check(arr):
			break
	print(*arr)
for i in range(ip()):
	main()


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [i for i in a if i > 0]
	c = [i for i in a if i < 0]
	d = [0] * a.count(0)
	if sum(b) == -sum(c):
		print('NO')
		continue
	if sum(b) > -sum(c):
		print('YES')
		print(*b + d + c, end=' ', sep=' ')
		print()
	else:
		print('YES')
		print(*c + d + b, end=' ', sep=' ')
		print()


t = input()
t = int(t)

def solve(n, arr):
	totalSum = sum(arr)
	if totalSum == 0:
		print('NO')
	elif totalSum > 0:
		arr.sort(reverse=True)
		print('YES')
		print(*arr)
	else:
		arr.sort()
		print('YES')
		print(*arr)
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().split()))
	solve(n, arr)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	sum = 0
	for i in l:
		sum += i
	if sum == 0:
		print('NO')
	else:
		print('YES')
		if sum > 0:
			l.sort(reverse=True)
		else:
			l.sort()
		for i in l:
			print(i, end=' ')
		print()
		l.clear()


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	s = sum(a)
	if s == 0:
		print('No')
	else:
		b = []
		sun = 0
		sup = 0
		for i in a:
			if i < 0:
				sun += i
			else:
				sup += i
		if sup > abs(sun):
			for i in a:
				if i > 0:
					b.append(i)
			for i in a:
				if i <= 0:
					b.append(i)
		else:
			for i in a:
				if i < 0:
					b.append(i)
			for i in a:
				if i >= 0:
					b.append(i)
		print('Yes')
		print(*b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		b1 = sorted(a)
		print('YES')
		b2 = b1[::-1]
		if b1[0] == 0:
			print(*b2)
		elif b2[0] == 0:
			print(*b1)
		else:
			s = b1[0]
			ok = True
			for i in range(1, n):
				s += b1[i]
				if s == 0:
					ok = False
					break
			if ok:
				print(*b1)
			else:
				print(*b2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	p = 0
	for i in a:
		if i > 0:
			p += i
		else:
			m += i
	m = m * -1
	if m > p:
		a.sort()
		print('Yes')
		print(*a)
	elif p > m:
		a.sort(reverse=True)
		print('Yes')
		print(*a)
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
		continue
	a = sorted(a, reverse=True if sum(a) > 0 else False)
	sm = 0
	f = 0
	for i in a:
		sm += i
		if sm == 0:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')
		print(*a)


import math
import os
import random
import re
import sys

def find_non_zero_set(xs):
	set_sum = sum(xs)
	if set_sum == 0:
		print('NO')
		return
	print('YES')
	sorted_xs = sorted(xs)
	if set_sum > 0:
		sorted_xs = sorted_xs[::-1]
	print(' '.join(map(str, sorted_xs)))

def solve(t):
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		find_non_zero_set(a)
t = int(input())
result = solve(t)


l = []
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		l.append('NO')
		continue
	n = 0
	p = 0
	for i in range(len(a)):
		if a[i] > 0:
			p = p + a[i]
		else:
			n = n + a[i]
	if abs(n) < p:
		l.append('YES')
		a.sort(reverse=True)
		b = [str(a[i]) for i in range(len(a))]
		l.append(' '.join(b))
	else:
		l.append('YES')
		a.sort()
		b = [str(a[i]) for i in range(len(a))]
		l.append(' '.join(b))
for i in l:
	print(i)


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	minus = 0
	plus = 0
	for x in data:
		if x < 0:
			minus += -x
		else:
			plus += x
	if sum(data) == 0:
		print('NO')
	else:
		if minus > plus:
			data.sort()
		else:
			data.sort(reverse=True)
		print('YES')
		for x in data:
			print(x, end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	if sum(l) == 0:
		print('NO')
	elif sum(l) < 0:
		l = sorted(l)
		print('YES')
		for i in range(n):
			print(l[i], end=' ')
		print()
	elif sum(l) > 0:
		print('YES')
		l = sorted(l, reverse=True)
		for i in range(n):
			print(l[i], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	sa = sum(a)
	a.sort()
	if sum(a) == 0:
		print('NO')
		continue
	if sum(a) > 0:
		a.reverse()
	print('YES')
	print(*a)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	inp = [int(i) for i in input().split()]
	(sumPos, sumNeg) = (0, 0)
	for i in range(len(inp)):
		if inp[i] < 0:
			sumNeg += inp[i]
		else:
			sumPos += inp[i]
	if abs(sumNeg) > sumPos:
		inp.sort()
	else:
		inp.sort(reverse=True)
	if sumPos + sumNeg == 0:
		print('NO')
		continue
	else:
		print('YES')
		for i in range(len(inp)):
			print(inp[i], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	poslist = []
	neglist = []
	zlist = []
	pos = 0
	neg = 0
	for i in range(n):
		if a[i] == 0:
			zlist.append(0)
		elif a[i] < 0:
			neglist.append(a[i])
			neg -= a[i]
		else:
			poslist.append(a[i])
			pos += a[i]
	ret = []
	if neg > pos:
		ret = neglist + zlist + poslist
		print('YES')
		print(*ret, sep=' ')
	elif pos > neg:
		ret = poslist + zlist + neglist
		print('YES')
		print(*ret, sep=' ')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		c = 0
		h = []
		d = []
		b = 0
		for i in l:
			if i < 0:
				h.append(i)
				b += i
			elif i == 0:
				c += 1
			else:
				d.append(i)
		a = sum(d)
		if a > -1 * b:
			ans = d + h + [0] * c
		else:
			ans = h + d + [0] * c
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
	elif s < 0:
		print('YES')
		print(' '.join(map(str, sorted(l))))
	else:
		print('YES')
		print(' '.join(map(str, sorted(l, reverse=True))))


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	sump = 0
	sumi = 0
	a = [int(i) for i in input().split(' ')]
	for i in range(n):
		if a[i] <= 0:
			sumi += a[i]
		else:
			sump += a[i]
	a.sort()
	if abs(sumi) > sump:
		trap = False
		check = 0
		for i in range(n):
			check += a[i]
			if check == 0:
				trap = True
				break
		if trap == True:
			print('NO')
		else:
			print('YES')
			for i in a:
				print(i, end=' ')
			print(' ')
	else:
		trap = False
		check = 0
		for i in range(n - 1, -1, -1):
			check += a[i]
			if check == 0:
				trap = True
				break
		if trap == True:
			print('NO')
		else:
			print('YES')
			for i in list(reversed(a)):
				print(i, end=' ')
			print(' ')


from sys import stdout, stdin
from io import IOBase, BytesIO
from os import read, write, fstat
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 = read(self._fd, max(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, size: int=...):
		while self.newlines == 0:
			b = read(self._fd, max(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:
			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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')

def problem_A(list_length, input_list):
	total_sum = sum(input_list)
	if total_sum == 0:
		print('NO')
		return
	print('YES')
	b = []
	if total_sum > 0:
		input_list.sort(reverse=True)
		for i in input_list:
			b.append(i)
	else:
		input_list.sort()
		for i in input_list:
			b.append(i)
	j = [str(x) for x in b]
	print(' '.join(j))
num_tests = int(input())
for _ in range(num_tests):
	len_list = int(input())
	str_form_list = [int(x) for x in input().split()]
	problem_A(len_list, str_form_list)


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		s = 0
		r = False
		for i in range(n):
			s += arr[i]
			if s == 0:
				r = True
		if r:
			arr.reverse()
		print(*arr)
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')
for _ in range(int(input())):
	main()


test_cases = int(input())
for test_case in range(test_cases):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	sum = 0
	for i in a:
		sum += i
	if sum == 0:
		print('NO')
	elif sum > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	else:
		a.sort()
		print('YES')
		print(*a)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		su = 0
		f = 0
		for i in range(n):
			su += a[i]
			if su == 0:
				f = 1
				break
		if f:
			print(*a[::-1])
		else:
			print(*a)


t = int(input())
for _ in range(t):
	l = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		print(' '.join([str(i) for i in sorted(a, reverse=sum(a) > 0)]))


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	ar = map(lambda x: int(x), s.split(' '))
	a = list(ar)
	zero = a.count(0)
	li = []
	if zero > 0:
		for i in range(0, zero):
			li.append(0)
			a.remove(0)
	if zero == n or sum(a) == 0:
		print('NO')
	else:
		n = len(a)
		i = 2
		c = -1
		while i < n:
			if sum(a[0:i]) == 0:
				c = (c + 1) % n
				(a[i - 1], a[c]) = (a[c], a[i - 1])
				i = 1
			i = i + 1
		print('YES')
		a = a + li
		for j in range(0, len(a)):
			if j == len(a) - 1:
				print(a[j])
			else:
				print(a[j], end=' ')
	t = t - 1


def solve():
	n = int(input())
	v1 = []
	v2 = []
	s = 0
	a = list(map(int, input().split()))
	for i in range(n):
		s += a[i]
		if a[i] >= 0:
			v1.append(a[i])
		else:
			v2.append(a[i])
	v1.sort(reverse=True)
	v2.sort()
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		for _ in range(len(v1)):
			print(v1[_], end=' ')
		for _ in range(len(v2)):
			print(v2[_], end=' ')
		print('')
	else:
		print('YES')
		for _ in range(len(v2)):
			print(v2[_], end=' ')
		for _ in range(len(v1)):
			print(v1[_], end=' ')
		print('')
t = int(input())
for i in range(t):
	solve()


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
from itertools import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

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

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	if sum(a) == 0:
		print('NO')
		continue
	a.sort()
	print('YES')
	s = 0
	for i in a:
		s += i
		if s == 0:
			s = 1.5
			break
	if s == 1.5:
		a = a[::-1]
	print(*a)


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

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

def fn(n):
	i = 2
	res = n - 1
	val = 0
	for i in range(int(sqrt(n)) + 1, 1, -1):
		val = i - 1 + int(ceil((n - i) / i))
		if val <= res:
			res = val
		else:
			break
	return res

def solve(a, b, c):
	dis = b ** 2 - 4 * a * c
	ans1 = (-b - sqrt(dis)) / (2 * a)
	print(int(ans1))
	return
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	elif sum(a) > 0:
		print('YES')
		a.sort(reverse=True)
		print(*a)
	else:
		print('YES')
		a.sort()
		print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		k = 0
		while k < n:
			if sum(a[:k + 1]) == 0:
				a = a[1:] + [a[0]]
				k = 0
			else:
				k += 1
		print(*a)


t = int(input())
for _ in range(t):
	x = int(input())
	a = list(map(int, input().split()))
	np = True
	sp = 0
	sn = 0
	for i in range(x):
		if a[i] > 0:
			sp += a[i]
			np = False
		elif a[i] < 0:
			sn += a[i]
			np = False
	if np == True:
		print('NO')
	elif sp + sn == 0:
		print('NO')
	else:
		print('YES')
		if sp < abs(sn):
			a.sort()
		else:
			a.sort(reverse=True)
		for i in a:
			print(i, end=' ')
		print()


import sys
t = int(input())

def answer(n, a):
	b = list(a)
	b.sort()
	s = sum(b)
	if s > 0:
		print('YES')
		print(' '.join([str(b[n - i - 1]) for i in range(n)]))
	elif s < 0:
		print('YES')
		print(' '.join([str(b[i]) for i in range(n)]))
	else:
		print('NO')
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	answer(n, a)


from sys import stdin, stdout
from collections import deque
import bisect
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(input())
for _ in range(T):
	n = int(input())
	l = RL(int)
	visited = [0] * n
	if sum(l) == 0:
		print('NO')
		continue
	if sum(l) < 0:
		print('YES')
		l.sort()
		print(*l)
	else:
		l.sort(reverse=True)
		print('YES')
		print(*l)


import sys
z = sys.stdin.readline
o = []
for _ in range(int(z())):
	n = int(z())
	a = [*map(int, z().split())]
	s = sum(a)
	if s == 0:
		o.append('NO')
		continue
	o.append('YES')
	o.append(' '.join(map(str, sorted(a, reverse=s > 0))))
print('\n'.join(o))


for i in range(int(input())):
	n = int(input())
	l = [int(c) for c in input().split()]
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l = sorted(l, reverse=True)
		print(*l)
	else:
		l = sorted(l)
		print('YES')
		print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = a
	y = sum(b)
	if y != 0:
		print('YES')
		print(*sorted(b, reverse=y > 0))
	else:
		print('NO')


t = int(input())
arr = []
for _ in range(t):
	input()
	arr.append(list(map(int, input().split())))
for tup in arr:
	if sum(tup) == 0:
		print('NO')
		continue
	print('YES')
	tup2 = sorted(tup)
	tup.sort(reverse=True)
	cursum = 0
	for k in tup:
		cursum += k
		if cursum == 0:
			break
	if cursum == 0:
		tup2 = list(map(str, tup2))
		print(' '.join(tup2))
	else:
		tup = list(map(str, tup))
		print(' '.join(tup))


import sys
import math
import itertools
input = sys.stdin.readline
ttt = int(input())
for tt in range(ttt):
	n = int(input())
	a = [int(x) for x in input().split()]
	plus = []
	minus = []
	ans = []
	for x in a:
		if x < 0:
			minus.append(x)
		else:
			plus.append(x)
	plus.sort(reverse=True)
	minus.sort(reverse=False)
	if sum(a) == 0:
		print('NO')
		continue
	elif sum(a) < 0:
		for x in minus:
			ans.append(x)
		for x in plus:
			ans.append(x)
	else:
		for x in plus:
			ans.append(x)
		for x in minus:
			ans.append(x)
	print('YES')
	print(*ans)


n = int(input())
for i in range(n):
	k = int(input())
	l = list(map(int, input().split()))
	p = 0
	o = 0
	s = 0
	for j in range(k):
		s += l[j]
	if s == 0:
		print('NO')
	else:
		print('YES')
	if s > 0:
		for j in range(k):
			if l[j] > 0:
				print(l[j], end=' ')
		for j in range(k):
			if l[j] == 0:
				print(l[j], end=' ')
		for j in range(k):
			if l[j] < 0:
				print(l[j], end=' ')
		print()
	if s < 0:
		for j in range(k):
			if l[j] < 0:
				print(l[j], end=' ')
		for j in range(k):
			if l[j] == 0:
				print(l[j], end=' ')
		for j in range(k):
			if l[j] > 0:
				print(l[j], end=' ')
		print()


t = int(input())
for hh in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split()]
	su = sum(a)
	pos = []
	neg = []
	zer = []
	for i in range(0, n):
		if a[i] > 0:
			pos.append(a[i])
		elif a[i] < 0:
			neg.append(a[i])
		else:
			zer.append(a[i])
	if su == 0:
		print('NO')
	elif su > 0:
		print('YES')
		for i in range(0, len(pos)):
			print(pos[i], end=' ')
		for i in range(0, len(zer)):
			print(zer[i], end=' ')
		for i in range(0, len(neg)):
			print(neg[i], end=' ')
	else:
		print('YES')
		for i in range(0, len(neg)):
			print(neg[i], end=' ')
		for i in range(0, len(zer)):
			print(zer[i], end=' ')
		for i in range(0, len(pos)):
			print(pos[i], end=' ')
	print()


def swap(xs, i, j):
	tmp = xs[i]
	xs[i] = xs[j]
	xs[j] = tmp

def solve(xs):
	sum_ = 0
	i = 0
	n = len(xs)
	while i < n:
		x = xs[i]
		sum_ += x
		if sum_ == 0:
			sum_ -= x
			j = i + 1
			y = x
			while j < n:
				if xs[j] != x:
					y = xs[j]
					break
				j += 1
			if x == y:
				return False
			swap(xs, i, j)
			sum_ += xs[i]
		i += 1
	return True

def helper(xs):
	n = len(xs)
	attempts = 0
	ans = False
	while not ans and attempts < n:
		ans = solve(xs)
		if ans:
			break
		last = xs.pop()
		xs.insert(0, last)
		attempts += 1
	return ans

def main(input_path=0):
	with open(input_path) as f:
		t = int(f.readline().strip())
		for _ in range(t):
			n = f.readline()
			xs = [int(x) for x in f.readline().strip().split(' ')]
			if helper(xs):
				print('YES')
				for x in xs:
					print(x, end=' ')
				print()
			else:
				print('NO')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		po = 0
		ng = 0
		for i in a:
			if i < 0:
				ng += i
			else:
				po += i
		if po > abs(ng):
			a.sort(reverse=True)
		else:
			a.sort()
		print(*a)


t = int(input(''))
while t > 0:
	a = int(input())
	n = [int(n) for n in input().split()]
	if sum(n) == 0:
		print('NO')
	else:
		if sum(n) > 0:
			n.sort(reverse=True)
		else:
			n.sort()
		print('YES')
		for j in n:
			print(j, end=' ')
		print(' ')
	t -= 1


import sys

def solve(num: list):
	total = sum(num)
	if total > 0:
		num.sort(reverse=True)
		return 'YES %s' % ' '.join([str(i) for i in num])
	if total < 0:
		num.sort(reverse=False)
		return 'YES %s' % ' '.join([str(i) for i in num])
	return 'NO'
for (no, line) in enumerate(sys.stdin):
	if no == 0:
		continue
	if no % 2 == 1:
		continue
	data = [int(i) for i in line.split(' ')]
	print(solve(data))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	acc = 0
	bad = False
	for e in arr:
		acc += e
		if acc == 0:
			bad = True
			break
	if not bad:
		print('YES')
		print(*arr)
		continue
	arr.reverse()
	acc = 0
	bad = False
	for e in arr:
		acc += e
		if acc == 0:
			bad = True
			break
	if not bad:
		print('YES')
		print(*arr)
		continue
	print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	else:
		b = []
		my_sum = 0
		f = 1
		a = arr.copy()
		while True:
			x = len(b)
			if x == n:
				break
			for i in range(len(arr)):
				if my_sum + arr[i] != 0:
					b.append(arr[i])
					my_sum += arr[i]
					arr.remove(arr[i])
					break
			y = len(b)
			if x == y:
				b = []
				a_mod = [0] * n
				for i in range(n):
					a_mod[(i + 1) % n] = a[i]
				arr = a_mod.copy()
				a = a_mod.copy()
				my_sum = 0
		print('YES')
		print(*b)


import math

class Solution:

	def __init__(self):
		pass

	def run(self):
		n = int(input())
		a = [int(x) for x in input().split()]
		result = []
		current = 0
		pos = []
		sumpos = 0
		neg = []
		sumneg = 0
		zero = []
		for i in a:
			if i < 0:
				neg.append(i)
				sumneg += i
			elif i > 0:
				pos.append(i)
				sumpos += i
			else:
				zero.append(i)
		if len(pos) == 0 and len(neg) == 0:
			return None
		if len(pos) == 0:
			return neg + zero
		if len(neg) == 0:
			return pos + zero
		if sumpos > abs(sumneg):
			return pos + neg + zero
		if abs(sumneg) > sumpos:
			return neg + pos + zero
		return None
t = int(input())
s = Solution()
for i in range(t):
	a = s.run()
	if a == None:
		print('NO')
		continue
	print('YES')
	print(' '.join([str(x) for x in a]).strip())


for _ in range(int(input())):
	n = int(input())
	an = list(map(int, input().split()))
	pos = []
	neg = []
	zer = []
	for a in range(n):
		if an[a] > 0:
			pos.append(an[a])
		elif an[a] == 0:
			zer.append(an[a])
		else:
			neg.append(an[a])
	if sum(pos) > abs(sum(neg)):
		print('YES')
		print(*pos + neg + zer)
	elif abs(sum(neg)) > sum(pos):
		print('YES')
		print(*neg + pos + zer)
	else:
		print('NO')


def avoiding_zero():
	test_cases = int(input())
	for t in range(test_cases):
		n = [int(x) for x in input().split(' ')]
		arr = [int(x) for x in input().split(' ')]
		sum_elems = sum(arr)
		if sum_elems == 0:
			print('NO')
		else:
			print('YES')
			poz = False if sum_elems < 0 else True
			poz_elems = sorted([x for x in arr if x >= 0], reverse=True)
			neg_elems = sorted([x for x in arr if x < 0])
			if poz:
				print(*poz_elems, *neg_elems)
			else:
				print(*neg_elems, *poz_elems)
avoiding_zero()


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	if sum(arr) == 0:
		print('NO')
	else:
		arr.sort(reverse=True)
		found = False
		sm = 0
		for i in range(n):
			sm += arr[i]
			if sm == 0:
				found = True
		if found:
			arr = arr[::-1]
		found = False
		sm = 0
		for i in range(n):
			sm += arr[i]
			if sm == 0:
				found = True
		if found:
			print('NO')
		else:
			print('YES')
			for i in arr:
				print(i, end=' ')
			print()


import sys
input = sys.stdin.readline
from itertools import accumulate
from operator import add
from random import shuffle
yes = lambda xs: 'YES\n' + ' '.join(map(str, xs))

def solveA(xs):
	if sum(xs) == 0:
		return 'NO'
	xs = list(sorted(xs))
	if 0 not in accumulate(xs, add):
		return yes(xs)
	if 0 not in accumulate(xs[::-1], add):
		return yes(xs[::-1])
	while True:
		xs.shuffle()
		if 0 not in accumulate(xs, add):
			return yes(xs)
t = int(input())
for _ in range(t):
	input()
	xs = [int(x) for x in input().split()]
	print(solveA(xs))


a = int(input())
for i in range(0, a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	e = ''
	for i in c:
		e += str(i) + ' '
	if sum(c) == 0:
		print('No')
	elif sum(c) < 0:
		print('Yes')
		print(*c)
	else:
		print('Yes')
		print(*c[::-1])


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

	def check(a):
		p = [0] * (n + 1)
		i = 1
		for v in a:
			p[i] = p[i - 1] + v
			i += 1
		return p[1:].count(0) == 0
	ans = sorted(mints())
	if not check(ans):
		ans.reverse()
	if not check(ans):
		print('NO')
	else:
		print('YES')
		print(*ans)
for i in range(mint()):
	solve()


for _ in range(int(input())):
	input()
	w = sorted(map(int, input().split()))
	if sum(w) > 0:
		print('YES')
		print(*w[::-1])
	elif sum(w) < 0:
		print('YES')
		print(*w)
	else:
		print('NO')


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])
t = inp()
while t > 0:
	t -= 1
	n = inp()
	arr = inlt()
	sum_arr = sum(arr)
	if sum_arr == 0:
		print('NO')
		continue
	else:
		print('YES')
	if sum_arr < 0:
		arr.sort()
		print(' '.join(map(str, arr)))
	else:
		arr.sort(reverse=True)
		print(' '.join(map(str, arr)))


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	(n, arr) = (INT(), ARR())
	arr.sort()
	s = sum(arr)
	if s == 0:
		print('NO')
		continue
	print('YES')
	if s < 0:
		print(JOIN(arr))
	else:
		print(JOIN(reversed(arr)))


for _ in range(int(input())):
	n = int(input())
	arr = [int(j) for j in input().split()]
	if sum(arr) == 0 or arr.count(0) == n:
		print('NO')
		continue
	if sum(arr) > 0:
		arr.sort(reverse=True)
		flag = 0
		sumi = arr[0]
		for i in range(1, n):
			if sumi == 0:
				flag = 1
				break
			sumi += arr[i]
			if sumi == 0:
				flag = 1
				break
		if flag == 0:
			print('Yes')
			print(*arr)
		else:
			print('No')
	else:
		arr.sort()
		flag = 0
		sumi = arr[0]
		for i in range(1, n):
			if sumi == 0:
				flag = 1
				break
			sumi += arr[i]
			if sumi == 0:
				flag = 1
				break
		if flag == 0:
			print('Yes')
			print(*arr)
		else:
			print('No')


from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

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

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = getlist()
		S = sum(A)
		if S == 0:
			print('NO')
		elif S < 0:
			A.sort()
			print('YES')
			print(*A)
		else:
			A.sort(reverse=True)
			print('YES')
			print(*A)
main()


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = [int(x) for x in input().split()]
		if sum(l) == 0:
			print('NO')
		else:
			print('YES')
			if sum(l) < 0:
				print(*sorted(l))
			else:
				print(*sorted(l, reverse=True))
except EOFError:
	pass


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	d = sum(a)
	if d == 0:
		print('NO')
	elif d < 0:
		print('YES')
		print(*sorted(a))
	else:
		print('YES')
		print(*sorted(a, reverse=True))


for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	s = sum(lst)
	if s == 0:
		print('NO')
		continue
	elif s > 0:
		lst.sort(reverse=True)
		print('YES')
		print(*lst, sep=' ')
	else:
		lst.sort()
		print('YES')
		print(*lst, sep=' ')


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

def gift():
	for _ in range(t):
		n = int(input())
		array = list(map(int, input().split()))
		sumA = sum(array)
		if sumA == 0:
			yield 'NO'
		else:
			yield 'YES'
			if sumA > 0:
				ans = sorted(array, reverse=True)
			else:
				ans = sorted(array)
			yield ' '.join((str(x) for x in ans))
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	pos = []
	neg = []
	zer = 0
	for i in range(len(list1)):
		if list1[i] > 0:
			pos.append(list1[i])
		elif list1[i] == 0:
			zer += 1
		else:
			neg.append(list1[i])
	p1 = sum(pos)
	p2 = abs(sum(neg))
	if p1 == p2:
		print('NO')
	elif p1 > p2:
		print('YES')
		print(*pos, end=' ')
		for j in range(zer):
			print(0, end=' ')
		print(*neg)
	else:
		print('YES')
		print(*neg, end=' ')
		for j in range(zer):
			print(0, end=' ')
		print(*pos)
	t -= 1


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	elif sum(a) < 0:
		a.sort()
		print('YES')
		print(*a)
	else:
		print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	a = inara()
	tot = 0
	for num in a:
		tot += num
	if tot == 0:
		print('NO')
		continue
	a.sort()
	tot = 0
	for num in a:
		tot += num
		if tot == 0:
			a.reverse()
			break
	print('YES')
	print(*a)


import sys
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def solve():
	n = getN()
	li = getList()
	if sum(li) == 0:
		print('NO')
		return
	z = []
	ol = []
	if sum(li) > 0:
		li.sort(reverse=True)
	else:
		li.sort()
	for ll in li:
		if ll != 0:
			ol.append(ll)
		else:
			z.append(ll)
	ans = ol + z
	print('YES')
	print(*ans)

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return map(int, input().strip().split())

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

def gets():
	return input()

def geta():
	return int(input())

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

def check(a):
	prev = 0
	for i in range(len(a)):
		if prev + a[i] == 0:
			return False
		prev += a[i]
	return True

def solve():
	for _ in range(geta()):
		n = geta()
		a = getl()
		if sum(a) == 0:
			print('NO')
			continue
		pos = []
		neg = []
		for i in a:
			if i > 0:
				pos.append(i)
			else:
				neg.append(i)
		print('YES')
		neg.sort()
		pos.sort()
		if check(neg + pos):
			print(*neg, *pos)
			continue
		if check(pos + neg):
			print(*pos, *neg)
			continue
		if check(neg + pos[::-1]):
			pos.reverse()
			print(*neg, *pos)
			continue
		if check(pos + neg[::-1]):
			neg.reverse()
			print(*pos, *neg)
			continue
		print(sorted(a))
solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	neg = []
	pos = []
	zero = []
	for i in range(n):
		if a[i] < 0:
			neg.append(a[i])
		elif a[i] > 0:
			pos.append(a[i])
		else:
			zero.append(0)
	if sum(pos) == -1 * sum(neg):
		print('NO')
	else:
		print('YES')
		if sum(pos) > -1 * sum(neg):
			print(*pos, *neg, *zero)
		else:
			print(*neg, *pos, *zero)


for _ in range(int(input())):
	n = int(input())
	daf = list(map(int, input().split()))
	sum_daf = sum(daf)
	if sum_daf == 0:
		print('NO')
	elif sum_daf > 0:
		daf = sorted(daf, reverse=True)
		print('YES')
		print(' '.join((str(x) for x in daf)))
	else:
		daf = sorted(daf)
		print('YES')
		print(' '.join((str(x) for x in daf)))


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	d = sum(c)
	if d == 0:
		print('NO')
	elif d < 0:
		print('YES')
		j = 0
		while j < len(c):
			if c[j] < 0:
				print(c[j], end=' ')
				c.pop(j)
			else:
				j += 1
		if not len(c):
			print()
		else:
			for j in range(len(c) - 1):
				print(c[j], end=' ')
			print(c[-1])
	else:
		print('YES')
		j = 0
		while j < len(c):
			if c[j] > 0:
				print(c[j], end=' ')
				c.pop(j)
			else:
				j += 1
		if not len(c):
			print()
		else:
			for j in range(len(c) - 1):
				print(c[j], end=' ')
			print(c[-1])


T = int(input())
while T:
	n = int(input())
	l = [int(k) for k in input().split()]
	l1 = []
	l2 = []
	l0 = []
	for i in l:
		if i < 0:
			l2.append(i)
		elif i > 0:
			l1.append(i)
		else:
			l0.append(0)
	s = sum(l)
	if s == 0:
		print('NO')
	elif s > 0:
		print('YES')
		for i in l1:
			print(i, end=' ')
		for i in l0:
			print(i, end=' ')
		for i in l2:
			print(i, end=' ')
		print()
	elif s < 0:
		print('YES')
		for i in l2:
			print(i, end=' ')
		for i in l0:
			print(i, end=' ')
		for i in l1:
			print(i, end=' ')
		print()
	T -= 1


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	if sum(a) == 0:
		print('NO')
		continue
	print('YES')
	if sum(a) < 0:
		a.sort()
		for i in a:
			print(i, end=' ')
	else:
		a.sort(reverse=True)
		for i in a:
			print(i, end=' ')
	print()


def solve():
	_ = input()
	arr = sorted([int(x) for x in input().strip().split()])
	if sum(arr) == 0:
		print('NO')
	else:
		print('YES')
		(final, b) = ([], [])
		sp = 0
		for a in arr:
			if sp + a == 0:
				final.append(a)
			else:
				b.append(a)
				sp += a
		b = b + final
		sp = 0
		for a in b:
			sp += a
			if sp == 0:
				b.reverse()
				break
		print(' '.join((str(x) for x in b)))
for _ in range(int(input().strip())):
	solve()


for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	s = sum(a)
	print(*(['YES'] + sorted(a, key=lambda x: -s * x or 9 ** 9), ['NO'])[s == 0])


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	if s == 0:
		print('NO')
		continue
	print('YES')
	if s > 0:
		ml = [i for i in arr if i > 0] + [i for i in arr if i == 0] + [i for i in arr if i < 0]
	else:
		ml = [i for i in arr if i < 0] + [i for i in arr if i == 0] + [i for i in arr if i > 0]
	print(*ml)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	sum = 0
	for e in arr:
		sum += e
	if sum != 0:
		print('YES')
		if sum < 0:
			arr.reverse()
		for e in arr:
			print(e, end=' ')
		print()
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	nums = [int(i) for i in input().split()]
	(pos, neg, zeroes) = ([], [], [])
	for num in nums:
		if num > 0:
			pos.append(num)
		elif num < 0:
			neg.append(num)
		else:
			zeroes.append(num)
	psum = sum(pos)
	nsum = abs(sum(neg))
	if psum != nsum:
		print('YES')
		if psum > nsum:
			print(' '.join([str(i) for i in pos + neg + zeroes]))
		else:
			print(' '.join([str(i) for i in neg + pos + zeroes]))
	else:
		print('NO')


import random

def f(a):
	s = a[0]
	i = 1
	while s != 0 and i < n:
		s += a[i]
		i += 1
	return s != 0
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		b = sorted(a)
		s = b[0]
		i = 1
		while s != 0 and i < n:
			s += b[i]
			i += 1
		if s == 0:
			b = b[::-1]
			s = b[0]
			i = 1
			while s != 0 and i < n:
				s += b[i]
				i += 1
			if s == 0:
				while True:
					random.shuffle(a)
					if f(a):
						print(*a)
						break
			else:
				print(*b)
		else:
			print(*b)


from random import shuffle

def check(lst):
	s = 0
	for i in range(len(lst)):
		s += lst[i]
		if s == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	s = sum(lst)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if check(sorted(lst, reverse=True)):
			print(*sorted(lst, reverse=True))
		elif check(sorted(lst)) == True:
			print(*sorted(lst))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
		continue
	temp = []
	b = []
	s1 = s2 = 0
	for i in arr:
		if i > 0:
			s1 += i
			temp.append(i)
	for i in arr:
		if i < 0:
			s2 += i
			temp.append(i)
	if abs(s1) < abs(s2):
		temp.reverse()
	for i in arr:
		if i == 0:
			temp.append(i)
	print('YES')
	print(*temp)


k = int(input())
for _ in range(k):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	if sum(a) == 0:
		print('NO')
		continue
	i = 0
	while i < len(a):
		ac = a.copy()
		temp = ac.pop(i)
		if sum(ac) != 0 or len(ac) == 0:
			b.insert(0, temp)
			a = ac
			i = 0
		else:
			i += 1
	if len(a) == 0:
		print('YES')
		print(*b)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if len(list(set(l))) == 1 and list(set(l))[0] == 0:
		print('NO')
	elif sum(l) == 0:
		print('NO')
	else:
		f = 0
		ans = []
		ans1 = []
		for i in range(n):
			if l[i] > 0:
				ans.append(l[i])
			else:
				ans1.append(l[i])
		ans1.sort()
		ans.sort(reverse=True)
		a = ans + ans1
		s = a[0]
		for i in range(1, len(a)):
			s = s + a[i]
			if s == 0:
				f = 1
				break
		if f == 1:
			print('YES')
			print(*ans1, *ans)
		else:
			print('YES')
			print(*a)


def check_arr():
	global rec, b
	x = 0
	arr2 = []
	for j in range(size_num):
		x += int(arr[j])
		arr2.append(x)
		if arr2[j] == 0:
			if rec == 2:
				arr.sort(reverse=False)
			if rec == 1:
				arr.sort(reverse=True)
			if rec > 0:
				rec -= 1
				check_arr()
				break
			else:
				b = False
				break
num = int(input())
outputs = []
for i in range(num):
	size_num = int(input())
	arr = input().split()
	b = True
	rec = 3
	arr2 = []
	check_arr()
	if b:
		outputs.append('YES')
		outputs.append(' '.join(arr))
		rec = 3
	else:
		outputs.append('NO')
		b = True
		rec = 3
print('\n'.join(outputs))


import sys
from itertools import permutations
n = int(input())
for i in range(n):
	num = int(input())
	arr = list(map(int, input().split()))
	a = permutations(arr, num)
	breaker = 0
	forbreak = 0
	bbreak = 0
	if sum(arr) == 0:
		print('NO')
	elif sum(arr) > 0:
		print('YES')
		arr.sort(reverse=True)
		print(' '.join(map(str, arr)))
	elif sum(arr) < 0:
		print('YES')
		arr.sort()
		print(' '.join(map(str, arr)))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		print('NO')
	elif s > 0:
		a.sort(reverse=True)
		print('YES')
		print(*a)
	else:
		a.sort()
		print('YES')
		print(*a)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pos = 0
	neg = 0
	for i in l:
		if i > 0:
			pos += i
		elif i < 0:
			neg += abs(i)
	if sum(l) == 0:
		print('NO')
	else:
		a = sorted(l)
		a1 = sorted(l)[::-1]
		print('YES')
		if neg > pos:
			print(*a, sep=' ')
		else:
			print(*a1, sep=' ')


N = int(input())
for i in range(0, N):
	T = int(input())
	L = list(map(int, input().split()))
	if sum(L) == 0:
		print('NO')
	else:
		print('YES')
		A = []
		B = []
		C = []
		for j in range(0, T):
			if L[j] > 0:
				A.append(L[j])
			elif L[j] == 0:
				B.append(L[j])
			else:
				C.append(L[j])
		A = sorted(A)
		C = sorted(C)
		if sum(A) > -1 * sum(C):
			D = A + C + B
			print(*D)
		else:
			D = C + A + B
			print(*D)


T = int(input())
for testcase in range(T):
	N = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) == 0:
		print('NO')
		continue
	elif sum(a) > 0:
		b = sorted(a, reverse=True)
	else:
		b = sorted(a)
	tmp = b[0]
	flag = 1
	for i in range(1, N):
		if tmp == 0:
			flag = 0
		tmp += b[i]
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(*b)


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

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

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

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

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

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		su = 0
		(temp, pos) = ([], [])
		for x in range(n):
			su += l[x]
			if su == 0:
				pos.append(x)
		if su == 0:
			no()
		else:
			su = 0
			ans = []
			flag = 0
			i = 0
			l.sort()
			q = 0
			while i < n:
				if su + l[i] == 0:
					j = i
					while su + l[i] == 0:
						l.append(l.pop(i))
						j += 1
						if j >= n:
							if q == 0:
								l.sort(reverse=True)
								ans.clear()
								su = 0
								i = 0
								q = 1
							else:
								flag = 1
								break
				su += l[i]
				ans.append(l[i])
				i += 1
			if flag:
				no()
				return
			yes()
			print(*ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


import sys
import math

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	k = int(input())
	a = get_array()
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		p = []
		n = []
		z = []
		ans = []
		for i in range(k):
			if a[i] > 0:
				p.append(a[i])
			elif a[i] < 0:
				n.append(a[i])
			else:
				z.append(a[i])
		if sum(p) > abs(sum(n)):
			ans = p + n
		elif abs(sum(n)) > sum(p):
			ans = n + p
		ans = ans + z
		print(*ans)


testcase_number = int(input())
for i in range(0, testcase_number):
	n = int(input())
	arr_list = list(map(int, input().split(' ')))
	positive_sum = 0
	negative_sum = 0
	arr_list.sort()
	for i in arr_list:
		if i < 0:
			negative_sum += i
		else:
			positive_sum += i
	if negative_sum + positive_sum == 0:
		print('NO')
		continue
	elif positive_sum > -negative_sum:
		arr_list = arr_list[::-1]
	print('YES')
	print(*arr_list, sep=' ')


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	else:
		l.sort()
		if sum(l) > 0:
			l.reverse()
		print('YES')
		print(*l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		bp = []
		bn = []
		z = []
		for i in range(n):
			if a[i] > 0:
				bp.append(a[i])
			elif a[i] < 0:
				bn.append(a[i])
			else:
				z.append(a[i])
		if sum(bp) + sum(bn) > 0:
			print(*bp, *bn, *z)
		else:
			print(*bn, *bp, *z)


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) == 0:
		print('NO')
	else:
		l.sort()
		print('YES')
		if sum(l) < 0:
			print(*l)
		else:
			l.reverse()
			print(*l)
t = int(input())
for _ in range(t):
	solve()


def recal(l):
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		pos = []
		neg = []
		zero = []
		for i in l:
			if i > 0:
				pos += [i]
			elif i == 0:
				zero += [i]
			else:
				neg += [i]
		if sum(pos) > abs(sum(neg)):
			for i in pos:
				print(i, end=' ')
			for i in zero:
				print(i, end=' ')
			for i in neg:
				print(i, end=' ')
		else:
			for i in neg:
				print(i, end=' ')
			for i in zero:
				print(i, end=' ')
			for i in pos:
				print(i, end=' ')
		print()
t = int(input())
while t > 0:
	int(input())
	l = list(map(int, input().split()))
	recal(l)
	t -= 1


import sys, os
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def main():
	ans = []
	for _ in range(int(input())):
		n = int(input())
		arr = read()
		if sum(arr) == 0:
			print('NO')
			continue
		arr.sort(reverse=True)
		s = 0
		fl = 0
		for i in arr:
			s += i
			if s == 0:
				fl = 1
		if not fl:
			print('YES')
			print(*arr)
			continue
		arr.sort()
		s = 0
		fl = 0
		for i in arr:
			s += i
			if s == 0:
				fl = 1
		print('YNEOS'[fl::2])
		if not fl:
			print(*arr)
main()


t = int(input())
for ti in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ansp = 0
	ansm = 0
	for i in range(len(a)):
		if a[i] > 0:
			ansp += a[i]
		else:
			ansm += a[i]
	if ansp == -ansm:
		print('NO')
	elif ansp > -ansm:
		a.sort(reverse=True)
		print('YES')
		print(' '.join(map(str, a)))
	else:
		a.sort()
		print('YES')
		print(' '.join(map(str, a)))


def f(a):
	res = sorted(a)
	c = sum(res)
	if c > 0:
		res = res[::-1]
	s = 0
	for i in res:
		print()
		s += i
		if s == 0:
			res = []
			break
	return res
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = f(a)
	if len(res) == 0:
		print('NO')
	else:
		print('YES')
		for i in res:
			print(i, end=' ')
		print()


def read_ints():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(sorted(read_ints()))
	tot = sum(a)
	if tot == 0:
		print('NO')
	elif tot < 0:
		print('YES')
		print(*a)
	elif tot > 0:
		print('YES')
		print(*a[::-1])


def getRes(n, lis):
	pos = []
	neg = []
	c = 0
	msum = 0
	for i in lis:
		msum += i
		if i > 0:
			pos.append(i)
		elif i == 0:
			c += 1
		else:
			neg.append(i)
	if msum == 0:
		return []
	res = []
	checkSum = 0
	if sum(pos) > abs(sum(neg)):
		for i in pos:
			res.append(i)
		for i in neg:
			res.append(i)
		for i in range(c):
			res.append(0)
	elif sum(pos) < abs(sum(neg)):
		for i in neg:
			res.append(i)
		for i in pos:
			res.append(i)
		for i in range(c):
			res.append(0)
	return res
t = int(input())
while t:
	n = int(input())
	lis = list(map(int, input().split()))
	res = getRes(n, lis)
	if len(res):
		print('YES')
		print(' '.join(map(str, res)))
	else:
		print('NO')
	t -= 1


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 10 ** 9 + 7
for t in range(int(data())):
	n = int(data())
	a = mdata()
	s = sum(a)
	if s == 0:
		out('NO')
	elif s < 0:
		out('YES')
		outl(sorted(a))
	else:
		out('YES')
		outl(sorted(a, reverse=True))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	nl = []
	pl = []
	sp = 0
	sn = 0
	for i in range(n):
		if a[i] < 0:
			nl.append(a[i])
			sn = sn - a[i]
		else:
			pl.append(a[i])
			sp = sp + a[i]
	pl.sort()
	pl = pl[::-1]
	if sp == sn:
		print('NO')
	elif sp > sn:
		ans = pl + nl
		print('YES')
		print(*ans)
	else:
		ans = nl + pl
		print('YES')
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	A = []
	B = []
	C = []
	a = b = 0
	for i in L:
		if i < 0:
			b = b + i
			B.append(i)
		elif i > 0:
			a = a + i
			A.append(i)
		else:
			C.append(i)
	if a + b == 0:
		print('NO')
	else:
		print('YES')
		if a > abs(b):
			for i in A:
				print(i, end=' ')
			for i in B:
				print(i, end=' ')
			for i in C:
				print(i, end=' ')
		else:
			for i in B:
				print(i, end=' ')
			for i in A:
				print(i, end=' ')
			for i in C:
				print(i, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	ans = False if sm == 0 else True
	if sm > 0:
		a.sort(reverse=True)
	else:
		a.sort()
	print('YES' if ans else 'NO')
	if ans:
		print(*a)


import sys, os
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve_(lst):
	lst = sorted(lst)
	cur = 0
	for a in lst:
		cur += a
		if cur == 0:
			break
	else:
		print('YES')
		return lst
	lst = lst[::-1]
	cur = 0
	for a in lst:
		cur += a
		if cur == 0:
			break
	else:
		print('YES')
		return lst
	print('NO')
	return ''

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	pass
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def console(*args):
		pass

def solve(*args):
	console('----- solving ------')
	console(*args)
	console('----- ------- ------')
	return solve_(*args)
if True:
	inp = iter(sys.stdin.buffer.readlines())
	input = lambda : next(inp)
else:
	input = sys.stdin.buffer.readline
for case_num in range(int(input())):
	_ = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	if not res:
		continue
	res = [str(x) for x in res]
	res = ' '.join(res)
	print(res)


cases = input()
for i in range(int(cases)):
	leng = input()
	nums = input().split()
	nums = [int(k) for k in nums]
	pos = [x for x in nums if x > 0]
	neg = [x for x in nums if x < 0]
	z = [x for x in nums if x == 0]
	if sum(pos) > -sum(neg):
		l = pos + neg + z
		print('YES')
		print(*l)
	elif -sum(neg) > sum(pos):
		l = neg + pos + z
		print('YES')
		print(*l)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()][:n]
	if sum(l) == 0:
		print('NO')
	else:
		x = sorted(l, reverse=True)
		cnt = 0
		for i in x:
			cnt += i
			if cnt == 0:
				l.sort()
				print('YES')
				print(*l)
				break
		else:
			print('YES')
			print(*x)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	p = []
	n = []
	if not sum(a):
		print('NO')
	else:
		for j in a:
			if j < 0:
				n.append(j)
			else:
				p.append(j)
		if p == [] or n == []:
			print('YES')
			if p != []:
				p.sort(reverse=True)
				print(*p)
			else:
				print(*n)
		else:
			print('YES')
			kk = sum(p)
			kkk = sum(n)
			p.sort(reverse=True)
			if abs(kkk) > abs(kk):
				n += p
				print(*n)
			else:
				p += n
				print(*p)


for _ in range(int(input())):
	n = input()
	a = list(map(int, input().split()))
	(pos, neg) = (0, 0)
	for i in a:
		if i > 0:
			pos += i
		else:
			neg += -i
	if pos == neg:
		print('No')
	else:
		print('Yes')
		if pos > neg:
			a = sorted(a, reverse=True)
		else:
			a.sort()
		for i in a:
			print(i, end=' ')
		print()


def cal(arr):
	s = sum(arr)
	if s == 0:
		return (False, None)
	if s > 0:
		return (True, sorted(arr, reverse=True))
	else:
		return (True, sorted(arr))

def web():
	T = int(input())
	for t in range(1, T + 1):
		_ = int(input())
		arr = [int(s) for s in input().split(' ')]
		(b, ans) = cal(arr)
		if b:
			print('YES')
			for a in ans:
				print(a, end=' ')
			print()
		else:
			print('NO')

def file():
	x = open('p1_in.txt')
	T = int(x.readline())
	for t in range(1, T + 1):
		_ = int(x.readline())
		arr = [int(s) for s in x.readline().split(' ')]
		(b, ans) = cal(arr)
		if b:
			print('YES')
			for a in ans:
				print(a, end=' ')
			print()
		else:
			print('NO')
web()


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	d = sum(l)
	if d < 0:
		l.sort()
		if l[0] == 0:
			(l[1], l[0]) = (l[0], l[1])
		print('YES')
		print(*l)
	elif d > 0:
		l.sort(reverse=True)
		if l[0] == 0:
			(l[1], l[0]) = (l[0], l[1])
		print('YES')
		print(*l)
	else:
		print('NO')


import math

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

def solve():
	n = int(input())
	a = getint()
	a_sum = sum(a)
	if a_sum == 0:
		print('NO')
	else:
		print('YES')
		if a_sum > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print(*a)
for _ in range(int(input())):
	solve()


for i in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	if sum(q) == 0:
		print('NO')
	else:
		print('YES')
		if sum(q) < 0:
			print(*sorted(q))
		else:
			print(*sorted(q, reverse=True))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	plus = 0
	minus = 0
	for val in a:
		if val > 0:
			plus += val
		else:
			minus -= val
	if plus == minus:
		print('NO')
		continue
	if plus > minus:
		a.sort(reverse=True)
	else:
		a.sort()
	print('YES')
	print(*a)


for s in [*open(0)][2::2]:
	a = s.split()
	b = []
	c = []
	for x in map(int, a):
		if x > 0:
			b += (x,)
		if x < 0:
			c += (x,)
	s = sum(b)
	t = -sum(c)
	print(*(['YES', *(b + c, c + b)[t > s]] + [0] * a.count('0'), ['NO'])[s == t])


def solution():
	n = int(input())
	l = [int(i) for i in input().split()]
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		l.sort(reverse=True)
		print('YES')
		for i in l:
			print(i, end=' ')
		print('')
	else:
		l.sort()
		print('YES')
		for i in l:
			print(i, end=' ')
		print('')
t = int(input())
for i in range(t):
	solution()


def solve():
	n = int(input())
	A = [int(x) for x in input().split()]
	S = sum(A)
	if S == 0:
		return None
	A = sorted(A)
	return A if S < 0 else A[::-1]
TC = int(input())
for _ in range(TC):
	res = solve()
	if res is None:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(str, res)))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	f = 0
	s = 0
	for i in range(len(l)):
		s += l[i]
		if s == 0:
			f = 1
			break
	if f == 0:
		print('YES')
		print(*l)
		continue
	l.sort(reverse=True)
	for j in range(len(l)):
		s += l[j]
		if s == 0:
			f = -1
			break
	if f == 1:
		print('YES')
		print(*l)
	if f == -1:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	(p, n) = ([], [])
	sp = 0
	sn = 0
	if sum(a) != 0:
		print('YES')
		for i in a:
			if i >= 0:
				sp += i
				p.append(str(i))
			else:
				sn += i
				n.append(str(i))
		f = []
		if sp > abs(sn):
			p.sort(reverse=True)
			n.sort()
			f = p + n
		else:
			f = n + p
			p.sort()
			n.sort(reverse=True)
		print(' '.join(f))
	else:
		print('NO')


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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

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

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

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = lis()
	b = []
	sum = 0
	flag = False
	present = {}
	sum2 = 0
	for i in a:
		sum2 += i
	if sum2 == 0:
		print('NO')
		continue
	a.sort()
	if sum2 > 0:
		a = a[::-1]
	print('YES')
	printlist(a)
	print()


for i in range(int(input())):
	n = input()
	l = list(map(int, input().split()))
	b = list(filter(lambda x: x > 0, l))
	m = sorted(list(filter(lambda x: x <= 0, l)))
	if abs(sum(b)) > abs(sum(m)):
		(print('YES'), print(*b + m))
	elif abs(sum(b)) < abs(sum(m)):
		(print('YES'), print(*m + b))
	else:
		print('NO')


for test in range(int(input())):
	pocet = int(input())
	a = list(map(int, input().split(' ')))
	b = []
	pos = True
	if sum(a) > 0:
		a.sort(reverse=True)
	elif sum(a) < 0:
		a.sort()
	else:
		pos = False
	b = [str(k) for k in a]
	if pos == False:
		print('NO')
	else:
		print('YES')
		print(' '.join(b))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = a[:]
	ans = 0
	a.sort(reverse=True)
	b.sort()
	s1 = 0
	s2 = 0
	c1 = 1
	c2 = 1
	for z in range(n):
		s1 += a[z]
		s2 += b[z]
		if not s1:
			c1 = 0
		if not s2:
			c2 = 0
	if c1:
		print('YES')
		print(*a)
		ans = 1
	elif c2 and (not ans):
		print('YES')
		print(*b)
	else:
		print('NO')


import sys

def read(func=int):
	return func(sys.stdin.readline())

def read_list(func=int):
	return list(map(func, sys.stdin.readline().strip().split()))
t = read()
while t:
	n = read()
	A = read_list()
	neg = [x for x in A if x < 0]
	pos = [x for x in A if x > 0]
	if -sum(neg) > sum(pos):
		print('YES')
		B = neg + [0] * A.count(0) + pos
		print(' '.join([str(x) for x in B]))
	elif -sum(neg) == sum(pos):
		print('NO')
	else:
		print('YES')
		B = pos + [0] * A.count(0) + neg
		print(' '.join([str(x) for x in B]))
	t -= 1


import sys
t = int(input().strip())
for a0 in range(t):
	a = int(input())
	l1 = [int(i) for i in input().split()]
	n = 0
	p = 0
	for i in l1:
		if i < 0:
			n += i
		else:
			p += i
	if abs(n) == p:
		print('NO')
	else:
		count = 0
		print('YES')
		if abs(n) > p:
			l1.sort()
		else:
			l1.sort()
			l1.reverse()
		s = ''
		for i in l1:
			if i == 0:
				count += 1
				continue
			s += str(i) + ' '
		s += count * '0 '
		print(s)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = list(map(int, input().split()))
		ss = sum(s)
		if ss == 0:
			print('NO')
			continue
		elif ss > 0:
			s.sort(reverse=True)
			print('YES')
			print(*s)
		elif ss < 0:
			s.sort()
			print('YES')
			print(*s)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		l1 = []
		l2 = []
		print('YES')
		pos = 0
		neg = 0
		z = []
		for i in range(n):
			if a[i] > 0:
				l1.append(a[i])
				pos = pos + a[i]
			elif a[i] < 0:
				l2.append(a[i])
				neg = neg + a[i]
			else:
				z.append(a[i])
		if pos > abs(neg):
			print(*l1, *l2, *z)
		else:
			print(*l2, *l1, *z)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) != 0 and sum(l) > 0:
		print('YES')
		pos = [i for i in l if i > 0]
		neg = [i for i in l if i < 0]
		zeros = sum([1 for i in l if i == 0])
		s = 0
		for i in range(len(neg)):
			if sum(pos) + neg[i] != 0:
				pos.append(neg[i])
			else:
				neg.append(neg[i])
		for i in range(zeros):
			pos.append(0)
		for i in pos:
			print(i, end=' ')
		print()
	elif sum(l) != 0 and sum(l) < 0:
		print('YES')
		pos = [i for i in l if i > 0]
		neg = [i for i in l if i < 0]
		zeros = sum([1 for i in l if i == 0])
		s = 0
		for i in range(len(pos)):
			if sum(neg) + pos[i] != 0:
				neg.append(pos[i])
			else:
				pos.append(pos[i])
		for i in range(zeros):
			neg.append(0)
		for i in neg:
			print(i, end=' ')
		print()
	else:
		print('NO')


import sys
t = int(input())
while t > 0:
	t -= 1
	n = int(sys.stdin.readline())
	input = sys.stdin.readline()
	ar = list(map(int, input.split()))
	sumi = 0
	for x in ar:
		sumi += x
	if sumi == 0:
		print('NO')
	else:
		print('YES')
		if sumi > 0:
			ar.sort()
			ar.reverse()
		else:
			ar.sort()
		print(*ar)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		neg = []
		pos = []
		for i in range(n):
			if a[i] >= 0:
				pos.append(a[i])
			else:
				neg.append(a[i])
		pos.sort(reverse=True)
		neg.sort()
		if sum(a) > 0:
			neg.reverse()
			ans = pos + neg
		else:
			pos.reverse()
			ans = neg + pos
		print(*ans)


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		if sum(a) == 0:
			print('NO')
		elif sum(a) > 0:
			a.sort(reverse=True)
			print('YES')
			print(*a)
		else:
			a.sort()
			print('YES')
			print(*a)

def B():
	t = int(input())
	for _ in range(t):
		print(t)

def C():
	t = int(input())
	for _ in range(t):
		print(t)

def D():
	t = int(input())
	for _ in range(t):
		print(t)
A()


import os, sys
from io import BytesIO, IOBase

def main():
	for i in range(int(input())):
		n = int(input())
		if n == 1:
			a = int(input())
			if a == 0:
				print('NO')
			else:
				print('YES')
				print(a)
		else:
			a = [int(x) for x in input().split()]
			a.sort()
			if sum(a) == 0:
				print('NO')
			else:
				sn = 0
				sp = 0
				for j in a:
					if j < 0:
						sn += j
					else:
						sn += j
				if sn < 0:
					an = a
				else:
					an = a[::-1]
				print('YES')
				print(*an)
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')
main()


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
GAP = 2
for t in [wtf[i:i + GAP] for i in range(1, len(wtf), GAP)]:
	n = int(t[0])
	A = list(map(int, t[1].split()))
	P = sorted([x for x in A if x > 0])
	N = sorted([x for x in A if x < 0])
	Z = [x for x in A if x == 0]
	Ps = sum(P)
	Ns = abs(sum(N))
	if Ps > Ns:
		print('YES\n' + ' '.join(map(str, P)) + ' ' + ' '.join(map(str, N)) + ' ' + ' '.join(map(str, Z)))
	elif Ps < Ns:
		print('YES\n' + ' '.join(map(str, N)) + ' ' + ' '.join(map(str, P)) + ' ' + ' '.join(map(str, Z)))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(sn, sp) = (0, 0)
	if sum(a) == 0:
		print('NO')
		continue
	for i in a:
		if i < 0:
			sn += i
		else:
			sp += i
	sn = abs(sn)
	print('YES')
	if sp > sn:
		a.sort(reverse=True)
		print(*a)
	else:
		a.sort()
		print(*a)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) == 0:
		print('NO')
	elif sum(arr) > 0:
		print('YES')
		p = sorted(arr)
		s = p[::-1]
		print(*s)
	else:
		print('YES')
		x = sorted(arr)
		print(*x)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		if sum(a) > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		for i in a:
			print(i, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	cn = 0
	cp = 0
	for i in ls:
		if i < 0:
			cn += i
		else:
			cp += i
	cn *= -1
	if cn == cp:
		print('NO')
	else:
		print('YES')
		if cn > cp:
			for i in ls:
				print(i, end=' ')
			print()
		else:
			for i in range(n - 1, -1, -1):
				print(ls[i], end=' ')
			print()


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 RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a.sort(reverse=True)
		else:
			a.sort()
		print_list(a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		pos = 0
		neg = 0
		for i in range(n):
			if a[i] > 0:
				pos += a[i]
			else:
				neg += abs(a[i])
		if pos > neg:
			print(*sorted(a)[::-1])
		else:
			print(*sorted(a))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	m = True
	if sum(arr) == 0:
		print('NO')
	else:
		print('Yes')
		arr.sort(reverse=True)
		for k in arr:
			count += k
			if count == 0:
				m = False
				arr.sort()
				print(*arr)
				break
		if m is True:
			print(*arr)


import bisect
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	if sum(l) == 0:
		print('NO')
	else:
		print('YES')
		if sum(l) < 0:
			print(*l[::-1])
		else:
			print(*l)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	s = sum(A)
	if s == 0:
		print('NO')
	else:
		print('YES')
		B = []
		C = []
		for i in range(n):
			if A[i] > 0:
				B.append(A[i])
			else:
				C.append(A[i])
		B.sort()
		C.sort()
		if -sum(C) > sum(B):
			A = C + B
		else:
			A = B + C
		print(*A)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		a = sorted(a)
		print('YES')
		new = []
		for i in range(len(a)):
			if sum(a[:i + 1]) == 0:
				a.reverse()
				break
		print(*a, sep=' ')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	neg_sum = 0
	pos_sum = 0
	pos = []
	neg = []
	zero = []
	sumi = sum(li)
	for i in li:
		if i < 0:
			neg_sum += i
			neg.append(i)
		elif i > 0:
			pos_sum += i
			pos.append(i)
		else:
			zero.append(i)
	neg_sum = -1 * neg_sum
	if neg_sum == pos_sum:
		print('NO')
	elif neg_sum > pos_sum:
		print('YES')
		print(' '.join(map(str, neg + pos + zero)))
	else:
		print('YES')
		print(' '.join(map(str, pos + neg + zero)))


def solve(arr):
	pos = []
	neg = []
	zeros = []
	if sum(arr) == 0:
		return ['NO']
	for ele in arr:
		if ele < 0:
			neg.append(ele)
		elif ele > 0:
			pos.append(ele)
		else:
			zeros.append(ele)
	if sum(arr) < 0:
		return ['YES', neg + zeros + pos]
	else:
		return ['YES', pos + zeros + neg]
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans.append(solve(arr))
for test in ans:
	print(test[0])
	try:
		for ele in test[1]:
			print(ele, end=' ')
		print()
	except:
		pass


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
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())
	if sum(arr) == 0:
		out('NO')
	else:
		(pos, neg) = (0, 0)
		for i in range(n):
			if arr[i] > 0:
				pos += arr[i]
			else:
				neg += abs(arr[i])
		if pos > neg:
			ans = []
			for i in range(n):
				if arr[i] > 0:
					ans.append(arr[i])
			for i in range(n):
				if arr[i] <= 0:
					ans.append(arr[i])
		else:
			ans = []
			for i in range(n):
				if arr[i] < 0:
					ans.append(arr[i])
			for i in range(n):
				if arr[i] >= 0:
					ans.append(arr[i])
		out('YES')
		print(*ans)


import sys
import math
x = 219837129873918273
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	neg = []
	pos = []
	zero = []
	for i in range(n):
		if a[i] < 0:
			neg.append(a[i])
		elif a[i] > 0:
			pos.append(a[i])
		else:
			zero.append(0)
	if sum(pos) == -1 * sum(neg):
		print('NO')
	else:
		print('YES')
		if sum(pos) > -1 * sum(neg):
			print(*pos, *neg, *zero)
		else:
			print(*neg, *pos, *zero)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		a.sort()
		b = []
		c = []
		for i in a:
			if i >= 0:
				b.append(i)
			else:
				c.append(i)
		if sum(b) > abs(sum(c)):
			b = b[::-1]
			print(*b + c)
		else:
			print(*c + b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pos = []
	neg = []
	cs = 0
	flag = 0
	for i in l:
		if i > 0:
			pos.append(i)
			fp = 1
		elif i < 0:
			neg.append(i)
		else:
			pos.append(i)
		cs += i
	if cs == 0:
		print('NO')
	elif cs < 0:
		print('YES')
		l.sort()
		print(*l)
	else:
		pos.sort(reverse=True)
		ans = pos + neg
		print('YES')
		print(*ans)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			a = a[::-1]
		a = [str(i) for i in a]
		print(' '.join(a))


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sums = sum(a)
	if sums == 0:
		print('NO')
		continue
	if sums > 0:
		a.sort(reverse=True)
	if sums < 0:
		a.sort()
	a = ' '.join(list(map(str, a)))
	print('YES')
	print(a)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	lst = list((int(x) for x in stdin.readline().split()))
	if sum(lst) > 0:
		lst.sort(reverse=True)
		print('YES')
		print(' '.join((str(x) for x in lst)))
	elif sum(lst) < 0:
		lst.sort()
		print('YES')
		print(' '.join((str(x) for x in lst)))
	else:
		print('NO')


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
pl = lambda l: print(' '.join(list(map(str, l))))
for _ in range(rn()):
	n = rn()
	l = rl()
	l.sort()
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		print('YES')
		if s > 0:
			pl(l[::-1])
		else:
			pl(l)


for _ in range(int(input())):
	n = int(input())
	b = [int(x) for x in input().split()]
	summ = sum(b)
	if summ == 0:
		print('NO')
	elif summ < 0:
		print('YES')
		print(*sorted(b))
	elif summ > 0:
		print('YES')
		print(*sorted(b, reverse=True))


from sys import stdin, stdout
import math
from collections import deque
input = stdin.readline

def print(*args, end='\n'):
	s = []
	for i in args:
		s.append(str(i) + ' ')
	s = ''.join(s)
	stdout.write(s + end)

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
		return
	print('YES')
	if s > 0:
		l.sort(reverse=True)
	else:
		l.sort()
	for i in l:
		print(i, end=' ')
	print()
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


from sys import stdin, stdout
ans = []

def main():
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	dictt = {}
	output = []
	sumval = sum(arr)
	if not sumval:
		ans.append('NO')
		return
	for item in arr:
		dictt[item] = dictt.get(item, 0) + 1
	rangearr = sorted(dictt.keys())
	if sumval > 0:
		rangearr = rangearr[::-1]
	for key in rangearr:
		output.extend([str(key) for _ in range(dictt[key])])
	if output[0] == '0':
		output = output[1:] + '0'
	ans.append('YES')
	ans.append(' '.join(output))
for _ in range(int(stdin.readline())):
	main()
stdout.write('\n'.join(ans))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	sum = 0
	stop = False
	arr.sort()
	for i in range(n):
		sum += arr[i]
		if sum == 0:
			sum -= arr[i]
			sum += arr[-1]
			if sum == 0:
				stop = True
				break
			else:
				(arr[i], arr[-1]) = (arr[-1], arr[i])
	if stop == True:
		arr = arr[-1::-1]
		sum = 0
		stop = False
		for i in range(n):
			sum += arr[i]
			if sum == 0:
				sum -= arr[i]
				sum += arr[-1]
				if sum == 0:
					stop = True
					break
				else:
					(arr[i], arr[-1]) = (arr[-1], arr[i])
		if stop == True:
			print('NO')
		else:
			print('YES')
			print(*arr)
	else:
		print('YES')
		print(*arr)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) == 0:
		print('NO')
	else:
		if sum(a) < 0:
			a.sort(key=lambda x: x)
		else:
			a.sort(key=lambda x: -x)
		print('YES')
		for x in a:
			print(x, end=' ')
		print()
	t -= 1


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	f = 0
	sum1 = 0
	for i in range(n):
		sum1 += lst[i]
		if sum1 == 0:
			f = 1
			break
	if f == 1:
		f = 0
		lst = lst[::-1]
		for i in range(n):
			sum1 += lst[i]
			if sum1 == 0:
				f = 1
				print('NO')
				break
	if f == 0:
		print('YES')
		print(*lst)


import sys
from sys import stdin
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	lst = list(map(int, stdin.readline().split()))
	s = sum(lst)
	if s == 0:
		print('NO')
	else:
		print('YES')
		lst.sort()
		if s > 0:
			lst.reverse()
			sys.stdout.write(' '.join(map(str, lst)) + '\n')
		else:
			sys.stdout.write(' '.join(map(str, lst)) + '\n')


import sys
input = iter(sys.stdin.read().splitlines()).__next__
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) == 0:
		print('NO')
	else:
		print('YES')
		positives = [a_i for a_i in a if a_i > 0]
		negatives = [a_i for a_i in a if a_i < 0]
		if sum(a) < 0:
			b = negatives + positives
		else:
			b = positives + negatives
		b += [0] * (len(a) - len(b))
		print(*b)


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	n = int(input())
	list1 = [int(x) for x in input().split()]
	t = sum(list1)
	if t == 0:
		print('NO')
	else:
		print('YES')
		list1 = sorted(list1)
		list2 = list1[::-1]
		if t > 0:
			print(*list2)
		else:
			print(*list1)


import sys, math, cmath, time, collections
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	q = [a[i] for i in range(len(a)) if a[i] < 0]
	w = [a[i] for i in range(len(a)) if a[i] >= 0]
	q.sort()
	w.sort()
	if sum(a) != 0:
		print('YES')
		qw = []
		qq = 0
		while q or w:
			if w and qq + w[-1] != 0:
				qw.append(w.pop())
			else:
				qw.append(q.pop())
			qq = qq + qw[-1]
		qq = 0
		ww = 0
		for i in range(len(qw)):
			qq = qq + qw[i]
			if qq == 0:
				ww = 1
		if ww == 1:
			q = [a[i] for i in range(len(a)) if a[i] < 0]
			w = [a[i] for i in range(len(a)) if a[i] >= 0]
			q.sort(reverse=True)
			w.sort(reverse=True)
			qw = []
			qq = 0
			while q or w:
				if q and qq + q[-1] != 0:
					qw.append(q.pop())
				else:
					qw.append(w.pop())
				qq = qq + qw[-1]
		print(*qw)
	else:
		print('NO')

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

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

def insr():
	return input().strip()

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

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

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

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


def solve(arr, n, s, temp):
	if n == 1 and s != 0:
		temp.insert(0, arr[0])
		return temp
	if s == 0:
		return None
	for i in range(n):
		if s - arr[i] != 0:
			temp.insert(0, arr[i])
			return solve([arr[j] for j in range(n) if j != i], n - 1, s - arr[i], temp)
T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split(' ')))
	temp = []
	arr = solve(a, n, sum(a), temp)
	if arr:
		print('YES')
		for num in arr:
			print(num, end=' ')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	sum_ = sum(arr)
	if sum_ == 0:
		print('NO')
	elif sum_ > 0:
		print('YES')
		arr.reverse()
		print(*arr)
	else:
		print('YES')
		print(*arr)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	for x in l:
		s += x
	if sum(l) == 0:
		print('NO')
	elif sum(l) > 0:
		print('YES')
		l.sort(reverse=True)
		print(*l)
	else:
		print('YES')
		l.sort()
		print(*l)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	if s == 0:
		print('NO')
	else:
		l.sort()
		if s > 0:
			print('YES')
			print(*l[-1::-1], sep=' ')
		else:
			print('YES')
			print(*l, sep=' ')