You are given an array a consisting of n integers.

Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.

Your task is to choose three positive (greater than 0) integers x, y and z such that:

  * x + y + z = n; 
  * max(1, x) = min(x + 1, x + y) = max(x + y + 1, n). 



In other words, you have to split the array a into three consecutive non-empty parts that cover the whole array and the maximum in the first part equals the minimum in the second part and equals the maximum in the third part (or determine it is impossible to find such a partition).

Among all such triples (partitions), you can choose any.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. Then t test cases follow.

The first line of the test case contains one integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the length of a.

The second line of the test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9), where a_i is the i-th element of a.

It is guaranteed that the sum of n does not exceed 2 ⋅ 10^5 (∑ n ≤ 2 ⋅ 10^5).

Output

For each test case, print the answer: NO in the only line if there is no such partition of a that satisfies the conditions from the problem statement. Otherwise, print YES in the first line and three integers x, y and z (x + y + z = n) in the second line.

If there are several answers, you can print any.

Example

Input


6
11
1 2 3 3 3 4 4 3 4 2 1
8
2 9 1 7 3 9 4 1
9
2 1 4 2 4 3 3 1 2
7
4 2 1 1 4 1 4
5
1 1 1 1 1
7
4 3 4 3 3 3 4


Output


YES
6 1 4
NO
YES
2 5 2
YES
4 1 2
YES
1 1 3
YES
2 1 4

Difficulty: HARD
Tags: Sorting

Amortized analysis

Data structures

Greedy algorithms
Skill types: Data structures

Sorting

Amortized analysis

Greedy algorithms

Starter code:

Solutions:
import math
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict
from bisect import bisect_left

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		dct = defaultdict(list)
		for (i, item) in enumerate(arr):
			dct[item].append(i)
		col = n.bit_length()
		sparse = [[-1 for _ in range(col)] for _ in range(n)]
		for c in range(col):
			for r in range(n):
				if c == 0:
					sparse[r][c] = r
					continue
				if r + (1 << c) <= n:
					z = 1 << c
					if arr[sparse[r][c - 1]] < arr[sparse[r + (z >> 1)][c - 1]]:
						sparse[r][c] = sparse[r][c - 1]
					else:
						sparse[r][c] = sparse[r + (z >> 1)][c - 1]
				else:
					break
		postmax = [0] * (n + 1)
		dctz = dict()
		for i in range(n):
			postmax[n - i - 1] = max(postmax[n - i], arr[n - i - 1])
		postmax.pop()
		for i in range(n - 2, -1, -1):
			if postmax[i] != postmax[i + 1]:
				dctz[postmax[i + 1]] = i
		dctz[postmax[0]] = -1

		def findmin(l, r):
			z = r - l + 1
			k = z.bit_length() - 1
			ans = arr[sparse[l][k]]
			z -= 1 << k
			if z:
				ans = min(ans, arr[sparse[l + z][k]])
			return ans
		pre = 0
		ans = 0
		for i in range(n):
			pre = max(pre, arr[i])
			if pre in dctz:
				y = dct[pre]
				x = bisect_left(y, i + 1)
				if x != len(y):
					z = max(y[x], dctz[pre])
					if z != n - 1 and findmin(i + 1, z) == pre and (postmax[z + 1] == pre):
						ans = [i + 1, z - i, n - z - 1]
						break
		if ans:
			print('YES')
			print(*ans)
		else:
			print('NO')
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
import io, os
input = sys.stdin.buffer.readline

class SparseTable:

	def __init__(self, A, ide_ele, f):
		n = len(A)
		self.f = f
		max_k = (n - 1).bit_length() - 1
		self.ide_ele = ide_ele
		self.table = [[ide_ele] * (max_k + 1) for i in range(n)]
		for i in range(n):
			self.table[i][0] = A[i]
		for k in range(1, max_k + 1):
			k2 = 1 << k - 1
			k3 = (1 << k) - 1
			for i in range(n - k3):
				self.table[i][k] = self.f(self.table[i][k - 1], self.table[i + k2][k - 1])

	def query(self, l, r):
		d = r - l
		if d == 1:
			return self.table[l][0]
		k = (d - 1).bit_length() - 1
		k2 = 1 << k
		return self.f(self.table[l][k], self.table[r - k2][k])
import bisect
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ST = SparseTable(A, 10 ** 18, min)
	L = [0] * n
	L[0] = A[0]
	for i in range(1, n):
		L[i] = max(L[i - 1], A[i])
	r = A[-1]
	for i in reversed(range(n)):
		r = max(r, A[i])
		x = bisect.bisect_right(L, r)
		if x == 0:
			continue
		v = min(x, i - 1)
		if v <= 0:
			continue
		if L[v - 1] == ST.query(v, i) and ST.query(v, i) == r:
			print('YES')
			print(v, i - v, n - i)
			break
		v -= 1
		if v <= 0:
			continue
		if L[v - 1] == ST.query(v, i) and ST.query(v, i) == r:
			print('YES')
			print(v, i - v, n - i)
			break
	else:
		print('NO')


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
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())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

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 = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

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 DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

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

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None
t = N()
for i in range(t):
	n = N()
	a = RLL()
	ma = max(a)
	res = []
	c = 0
	for (i, x) in enumerate(a):
		if x == ma:
			c += 1
			res.append(i + 1)
	if c >= 3:
		x = res[1] - 1
		y = 1
		z = n - x - y
		print('YES')
		print(x, y, z)
	else:
		l = r = res[0] - 1
		pre = [0] * n
		suf = [0] * n
		pre[0] = a[0]
		suf[n - 1] = a[n - 1]
		for i in range(l):
			pre[i] = max(pre[i - 1], a[i])
		for j in range(n - 2, r, -1):
			suf[j] = max(suf[j + 1], a[j])
		s = set(a)
		s = sorted(s, reverse=True)
		f = 0
		c = Counter()
		c[a[l]] += 1
		for j in range(1, len(s)):
			while r < n - 1 and a[r + 1] >= s[j]:
				c[a[r + 1]] += 1
				r += 1
			while l > 0 and a[l - 1] >= s[j]:
				l -= 1
				c[a[l]] += 1
			tmp = c[s[j]]
			x = l
			y = r + 1 - x
			if l == 0:
				if a[l] == s[j]:
					x = 1
					y -= 1
					tmp -= 1
				else:
					break
			elif pre[l - 1] > s[j]:
				continue
			elif pre[l - 1] < s[j]:
				if a[l] == s[j]:
					x += 1
					y -= 1
					tmp -= 1
				else:
					continue
			if r == n - 1:
				if a[r] == s[j]:
					tmp -= 1
					y -= 1
				else:
					break
			elif suf[r + 1] > s[j]:
				continue
			elif suf[r + 1] < s[j]:
				if a[r] == s[j]:
					y -= 1
					tmp -= 1
				else:
					continue
			if tmp:
				f = 1
				break
		if f:
			print('YES')
			print(x, y, n - x - y)
		else:
			print('NO')


import heapq

def heapu(counted, heee, f, d, e):
	for i in range(f, d, e):
		while len(heee) > 0 and heee[0][0] * -1 > a[i]:
			counted[heee[0][1]] = i - heee[0][1]
			heapq.heappop(heee)
		heapq.heappush(heee, [a[i] * -1, i])
	return counted
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	he = [[-a[0], 0]]
	plus = 0
	f_counted = []
	b_counted = []
	for i in range(n):
		b_counted.append(plus)
		plus -= 1
	plus = n - 1
	for i in range(n):
		f_counted.append(plus)
		plus -= 1
	counted_f = heapu(f_counted, he, 1, n - 1, 1)
	hee = [[-a[n - 1], n - 1]]
	counted_b = heapu(b_counted, hee, n - 1, 0, -1)
	f_maxi = []
	maxi = 0
	for i in range(0, n):
		maxi = max(maxi, a[i])
		f_maxi.append(maxi)
	b_maxi = []
	maxi = 0
	for i in range(n - 1, -1, -1):
		maxi = max(maxi, a[i])
		b_maxi.append(maxi)
	b_maxi = b_maxi[::-1]
	(x, y, z) = (-1, -1, -1)
	flag = 1
	for i in range(1, n - 1):
		(x, y, z) = (-1, -1, -1)
		if a[i] == b_maxi[i + counted_f[i]]:
			z = n - i - f_counted[i]
		elif a[i] == b_maxi[i + counted_f[i] - 1] and counted_f[i] > 1:
			z = n - i - f_counted[i] + 1
		if a[i] == f_maxi[i + counted_b[i]]:
			x = i + b_counted[i] + 1
		elif a[i] == f_maxi[i + counted_b[i] + 1] and counted_b[i] < -1:
			x = i + b_counted[i] + 1 + 1
		y = n - x - z
		if x > -1 and z > -1:
			flag = 0
			break
	if flag == 0:
		print('YES')
		print(x, y, z)
	else:
		print('NO')


import sys
input = sys.stdin.readline
import bisect
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	hashi = dict()
	for i in range(n):
		if li[i] in hashi:
			hashi[li[i]].append(i)
		else:
			hashi[li[i]] = []
			hashi[li[i]].append(i)
	maxpref = [0 for i in range(n)]
	maxsuff = [0 for i in range(n)]
	maxa = 0
	for i in range(n):
		maxa = max(maxa, li[i])
		maxpref[i] = maxa
	maxa = 0
	for i in range(n - 1, -1, -1):
		maxa = max(maxa, li[i])
		maxsuff[i] = maxa
	nextlow = [n for i in range(n)]
	prevlow = [-1 for i in range(n)]
	s = []
	for i in range(n):
		while s != [] and li[s[-1]] > li[i]:
			nextlow[s[-1]] = i
			s.pop(-1)
		s.append(i)
	for i in range(n - 1, -1, -1):
		while s != [] and li[s[-1]] > li[i]:
			prevlow[s[-1]] = i
			s.pop(-1)
		s.append(i)
	maxs = dict()
	maxe = dict()
	for i in range(n):
		maxs[maxpref[i]] = i
	for i in range(n - 1, -1, -1):
		maxe[maxsuff[i]] = i
	hashs = dict()
	hashe = dict()
	for i in range(n):
		if maxpref[i] not in hashs:
			hashs[maxpref[i]] = [i]
		else:
			hashs[maxpref[i]].append(i)
	for i in range(n):
		if maxsuff[i] not in hashe:
			hashe[maxsuff[i]] = [i]
		else:
			hashe[maxsuff[i]].append(i)
	poss = 0
	for i in range(n):
		if li[i] not in hashs or li[i] not in hashe:
			continue
		z = bisect.bisect_left(hashs[li[i]], i)
		z -= 1
		if z < 0 or z >= len(hashs[li[i]]) or hashs[li[i]][z] < prevlow[i]:
			continue
		y = bisect.bisect_right(hashe[li[i]], i)
		if y >= len(hashe[li[i]]) or hashe[li[i]][y] > nextlow[i]:
			continue
		poss = 1
		ans = (hashs[li[i]][z], hashe[li[i]][y])
		break
	if poss:
		print('YES')
		print(ans[0] + 1, ans[1] - ans[0] - 1, n - ans[1])
	else:
		print('NO')


import sys
rmq = []

def query(a, b):
	ii = len(bin(b - a)) - 3
	return min(rmq[ii][a], rmq[ii][b - (1 << ii) + 1])
for ttt in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	d = [int(i) for i in sys.stdin.readline().split()]
	lgn = len(bin(n - 1)) - 2
	rmq = [[0] * n for i in range(lgn)]
	for j in range(n):
		rmq[0][j] = d[j]
	for i in range(1, lgn):
		for j in range(n):
			rmq[i][j] = min(rmq[i - 1][j], rmq[i - 1][min(n - 1, j + (1 << i - 1))])
	mx1 = [0] * n
	mx1[0] = d[0]
	for i in range(1, n):
		mx1[i] = max(d[i], mx1[i - 1])
	mx2 = [0] * n
	mx2[n - 1] = d[n - 1]
	for i in range(n - 2, -1, -1):
		mx2[i] = max(d[i], mx2[i + 1])
	ans = [-1, -1]
	for x in range(n - 2):
		h = mx1[x]
		lo = x + 2
		hi = n - 1
		while lo < hi:
			mid = (lo + hi) // 2
			qq1 = query(x + 1, mid - 1)
			qq2 = mx2[mid]
			go_up = qq1 > h or qq2 > h
			go_down = qq1 < h or qq2 < h
			if go_up == go_down:
				break
			if go_up:
				lo = mid + 1
			else:
				hi = mid - 1
		y = (lo + hi) // 2
		if lo <= hi and h == mx2[y] and (h == query(x + 1, y - 1)):
			ans[0] = x
			ans[1] = y
			break
	if ans[0] == -1:
		sys.stdout.write('NO\n')
	else:
		sys.stdout.write(f'YES\n{ans[0] + 1} {ans[1] - ans[0] - 1} {n - ans[1]}\n')


import sys
from math import ceil, log2
INT_MAX = 10 ** 12

def minVal(x, y):
	return x if x < y else y

def getMid(s, e):
	return s + (e - s) // 2

def RMQUtil(st, ss, se, qs, qe, index):
	if qs <= ss and qe >= se:
		return st[index]
	if se < qs or ss > qe:
		return INT_MAX
	mid = getMid(ss, se)
	return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2))

def RMQ(st, n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input')
		return -1
	return RMQUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2))
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * int(2 ** x) - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st
for _ in range(int(input())):

	def solve():
		n = int(input())
		a = list(map(int, input().split()))
		st = constructST(a, n)
		left = [0] * (n + 1)
		right = [0] * (n + 1)
		for i in range(1, n + 1):
			left[i] = max(left[i - 1], a[i - 1])
			right[-i - 1] = max(right[-i], a[-i])
		for ri in range(1, n - 1):
			ma = right[-ri - 1]
			low = 1
			high = n - ri - 1
			while low < high:
				mid = (low + high + 1) // 2
				if left[mid] > ma:
					high = mid - 1
				else:
					low = mid
			if left[low] == ma and RMQ(st, n, low, n - ri - 1) == ma:
				print('YES')
				print(low, n - low - ri, ri)
				return
			if low > 1 and left[low - 1] == ma and (RMQ(st, n, low - 1, n - ri - 1) == ma):
				print('YES')
				print(low - 1, n - low - ri + 1, ri)
				return
		print('NO')
		return
	solve()


import heapq
T = int(input())
r = 1
while r <= T:
	n = int(input())
	arr = list(map(int, input().split()))
	third = [0] * n
	third[-1] = arr[-1]
	maxfre = 0
	for i in range(n - 2, -1, -1):
		third[i] = max(third[i + 1], arr[i])
	firstdic = {}
	temp = []
	secondindexnum = 0
	secondindexmin = 2147483647
	flag = False
	fuck = 0
	for i in range(n - 1):
		if arr[i] <= third[i + 1]:
			heapq.heappush(temp, [-arr[i], -i])
			if arr[i] not in firstdic:
				firstdic[arr[i]] = []
			firstdic[arr[i]].append(i)
		else:
			secondindexnum += 1
			secondindexmin = min(secondindexmin, i)
		while temp and -temp[0][0] > third[i + 1]:
			ele = heapq.heappop(temp)
			secondindexnum += 1
			secondindexmin = min(secondindexmin, -ele[1])
			if -ele[0] in firstdic:
				del firstdic[-ele[0]]
		if len(temp) < 2:
			continue
		if temp[0][0] != -third[i + 1]:
			continue
		maximum = heapq.heappop(temp)
		if temp[0][0] != -third[i + 1]:
			heapq.heappush(temp, maximum)
			continue
		heapq.heappush(temp, maximum)
		if secondindexnum == 0:
			flag = True
			(x, y, z) = (len(temp) - 1, 1, n - len(temp))
			break
		needed = i - secondindexmin + 1 - secondindexnum
		if len(temp) < needed + 1:
			continue
		if needed == 0 and -temp[0][1] == secondindexmin - 1:
			flag = True
			(x, y, z) = (secondindexmin - 1, i + 2 - secondindexmin, n - i - 1)
			break
		if needed > 0 and len(firstdic[third[i + 1]]) > needed:
			target = firstdic[third[i + 1]]
			if target[-needed] > secondindexmin:
				flag = True
				(x, y, z) = (secondindexmin, i + 1 - secondindexmin, n - i - 1)
			if flag:
				break
	if flag:
		print('YES')
		print(x, y, z)
	else:
		print('NO')
	r += 1


from collections import Counter, OrderedDict

def nint():
	return int(input())

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

def f():
	nint()
	A = nintA()
	n = len(A)
	m = max(A)
	(l, r, rr) = (0, 0, 0)
	try:
		l = A.index(m)
		r = A[l + 1:].index(m) + l + 1
		rr = A[r + 1:].index(m) + r + 1
	except:
		pass
	if rr:
		print('YES')
		return print(r, 1, n - r - 1)
	r = max(l, r)
	m = min(A[l:r + 1])
	MAX = [A[0]] + [0] * (n - 2) + [A[-1]]
	for i in range(1, l):
		MAX[i] = max(MAX[i - 1], A[i])
	for i in reversed(range(r + 1, n - 1)):
		MAX[i] = max(MAX[i + 1], A[i])
	(ll, rr) = (l - 1, r + 1)
	while rr < n and ll >= 0:
		m = min(m, A[ll + 1], A[rr - 1])
		if m == MAX[ll] and m == MAX[rr]:
			print('YES')
			return print(ll + 1, rr - ll - 1, n - rr)
		elif ll == 0:
			rr += 1
		elif rr == n - 1:
			ll -= 1
		elif min(m, MAX[ll - 1], MAX[rr], A[ll]) > min(m, MAX[ll], MAX[rr + 1], A[rr]):
			ll -= 1
		else:
			rr += 1
	print('NO')
t = int(input())
for i in range(t):
	f()


import math

class RMQ:

	def __init__(self, arr):
		self.n = len(arr)
		self.logn = int(math.log2(self.n)) + 1
		self.arr = [0] + arr
		self.Log = [0] * (self.n + 1)
		self.Log[2] = 1
		for i in range(3, self.n + 1):
			self.Log[i] = self.Log[i // 2] + 1
		self.min = [[0] * (self.logn + 1) for _ in range(self.n + 1)]
		for i in range(1, self.n + 1):
			self.min[i][0] = self.arr[i]

	def pre(self):
		for j in range(1, self.logn + 1):
			for i in range(1, self.n + 1):
				if i + (1 << j) - 1 > self.n:
					break
				self.min[i][j] = min(self.min[i][j - 1], self.min[i + (1 << j - 1)][j - 1])

	def queryMax(self, l, r):
		s = self.Log[r - l + 1]
		return max(self.max[l][s], self.max[r - (1 << s) + 1][s])

	def queryMin(self, l, r):
		s = self.Log[r - l + 1]
		return min(self.min[l][s], self.min[r - (1 << s) + 1][s])
from bisect import bisect, bisect_left
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	rmq = RMQ(A)
	rmq.pre()
	dic = {}
	cur = float('-inf')
	left = [A[0]]
	for i in range(1, n):
		left.append(max(left[-1], A[i]))
	right = [A[-1]]
	for i in range(n - 2, -1, -1):
		right.append(max(right[-1], A[i]))
	for i in range(n - 2):
		cur = left[i]
		(j, k) = (bisect(right, cur), bisect_left(right, cur))
		if right[k] != cur:
			continue
		(j, k) = (n - j, n - 1 - k)
		if k - i <= 1:
			break
		j = max(i + 2, j)
		dic[i] = (j, k)
	flag = 0
	for (i, (j, k)) in dic.items():
		while j <= k:
			m = (j + k) // 2
			tmp = rmq.queryMin(i + 2, m)
			if tmp == left[i]:
				flag = 1
				break
			elif tmp > left[i]:
				j = m + 1
			else:
				k = m - 1
		if flag:
			print('YES')
			print('{} {} {}'.format(i + 1, m - i - 1, n - m))
			break
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	X = list(map(int, input().split()))
	M = [-1] * N
	mx = 0
	INF = 10
	for i in range(N - 1, -1, -1):
		mx = max(X[i], mx)
		M[i] = mx
	M2 = [-1] * N
	mx = 0
	d = dict()
	Y = [-1] * N
	Z = [-1] * N
	stack = []
	for i in range(N):
		mx = max(X[i], mx)
		M2[i] = mx
	for i in range(N - 1, -1, -1):
		if M2[i] in d:
			Y[i] = d[M2[i]]
		d[X[i]] = i
	for i in range(N - 1, -1, -1):
		while stack and stack[-1][1] >= X[i]:
			stack.pop()
		if stack:
			Z[i] = stack[-1][0]
		stack.append((i, X[i]))
	Z2 = [-1] * N
	stack = []
	R = []
	for i in range(N - 1, -1, -1):
		while stack and stack[-1][1] >= M2[i]:
			stack.pop()
		if stack:
			Z2[i] = stack[-1][0]
		stack.append((i, X[i]))
	for i in range(N):
		if Y[i] == -1:
			continue
		if i < Z2[i] < Y[i]:
			continue
		if Z[Y[i]] == -1:
			if M2[i] == X[-1] and Y[i] != N - 1:
				R.append((i + 1, N - (i + 2), 1))
			continue
		if M[Z[Y[i]]] == M2[i]:
			R.append((i + 1, Z[Y[i]] - i - 1, N - Z[Y[i]]))
		if Y[i] != Z[Y[i]] - 1 and M[Z[Y[i]] - 1] == M2[i]:
			R.append((i + 1, Z[Y[i]] - i - 2, N - Z[Y[i]] + 1))
	if R:
		print('YES')
		print(*R[-1])
	else:
		print('NO')


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
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=10 ** 9 + 5, 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 = (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 = 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())
	l = list(map(int, input().split()))
	d = defaultdict(list)
	e = defaultdict(list)
	s = SegmentTree1(l)
	ma = 0
	for i in range(n - 1, -1, -1):
		ma = max(l[i], ma)
		d[ma].append(i)
	ind = defaultdict(list)
	nex = defaultdict(list)
	f = 0
	for i in d:
		d[i].sort()
		for t in range(len(d[i]) - 1):
			er = s.query(d[i][t], d[i][t + 1] - 1)
			if er == i:
				ind[i].append(d[i][t])
				nex[i].append(d[i][t + 1])
	m = 0
	for i in range(n):
		m = max(l[i], m)
		er = binarySearchCount(ind[m], len(ind[m]), i)
		we = binarySearchCount(d[m], len(d[m]), i)
		if we == len(d[m]):
			continue
		elif s.query(i + 1, d[m][we] - 1) == m:
			f = 1
			print('YES')
			print(i + 1, d[m][we] - i - 1, n - d[m][we])
			break
		elif er == len(ind[m]):
			continue
		else:
			ert = s.query(i + 1, ind[m][er] - 1)
			if ert >= m:
				print('YES')
				print(i + 1, nex[m][er] - i - 1, n - nex[m][er])
				f = 1
				break
	if f == 0:
		print('NO')


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

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

def solve(N, A):
	rmq = RangeQuery(A)
	maxLeft = [0]
	maxRight = [0]
	for x in A:
		maxLeft.append(max(maxLeft[-1], x))
	for x in A[::-1]:
		maxRight.append(max(maxRight[-1], x))
	for x in range(1, N):
		mx = maxLeft[x]
		index = bisect_right(maxRight, mx, 0, N - x - 1)
		for z in [index - 2, index - 1, index]:
			y = N - x - z
			if 1 <= y <= N and 1 <= z <= N and (maxRight[z] == mx == rmq.query(x, x + y)):
				return 'YES\n' + str(x) + ' ' + str(y) + ' ' + str(z)
	return 'NO'

def solveBrute(N, A):
	rangeMin = RangeQuery(A)
	rangeMax = RangeQuery(A, max)
	for x in range(1, N):
		for y in range(1, N):
			z = N - x - y
			if 1 <= y <= N and 1 <= z <= N:
				if rangeMax.query(0, x) == rangeMin.query(x, x + y) == rangeMax.query(x + y, x + y + z):
					return 'YES'
	return 'NO'
DEBUG = False
if DEBUG:
	import random
	random.seed(0)
	for _ in range(100000):
		N = random.randint(1, 10)
		A = [random.randint(1, 10) for i in range(N)]
		print('tc', _, N, A)
		ans1 = solve(N, A)
		ans2 = solveBrute(N, A)
		if (ans1 == 'NO' or ans2 == 'NO') and ans1 != ans2:
			print('ans1', ans1)
			print('ans2', ans2)
			assert False
	exit()
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)


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

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	(l, r, b) = ([0] * n, [n - 1] * n, defaultdict(list))
	for (i, v) in enumerate(a):
		b[v].append(i)
	s = [0]
	for i in range(1, n):
		while s and a[s[-1]] >= a[i]:
			s.pop()
		if s:
			l[i] = s[-1]
		s.append(i)
	s = [n - 1]
	for i in range(n - 2, -1, -1):
		while s and a[s[-1]] >= a[i]:
			s.pop()
		if s:
			r[i] = s[-1]
		s.append(i)
	(ml, mr) = ([a[0]], [a[-1]])
	for i in range(1, n):
		ml.append(max(ml[-1], a[i]))
		mr.append(max(mr[-1], a[-(i + 1)]))
	mr.reverse()
	for i in range(1, n - 1):
		z = b[a[i]]
		if z[0] != i and z[-1] != i:
			x = bisect_left(z, l[i])
			y = bisect_left(z, r[i])
			x -= z[x] == i
			y -= len(z) == y
			(xx, yy) = (max(z[x], l[i]), min(z[y], r[i]))
			if ml[xx] == mr[yy] == a[i]:
				print('YES')
				print(xx + 1, yy - xx - 1, n - yy)
				return
	print('NO')

def main():
	for t in range(int(input())):
		solve()
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 itertools import accumulate
from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	maa = max(aa)
	mpos = [i for (i, a) in enumerate(aa) if a == maa]
	if len(mpos) >= 3:
		print('YES')
		print(mpos[1], 1, n - mpos[1] - 1)
		return
	x = mpos[0]
	z = n - mpos[-1] - 1
	lmx = list(accumulate(aa[0:x], lambda a, b: max(a, b)))
	rmx = list(accumulate(aa[n - 1:n - z - 1:-1], lambda a, b: max(a, b)))
	cmn = min(aa[x:n - z])
	while x > 0 and z > 0:
		if lmx[x - 1] == rmx[z - 1]:
			if lmx[x - 1] == cmn:
				print('YES')
				print(x, n - x - z, z)
				return
			elif cmn < lmx[x - 1]:
				x -= 1
				z -= 1
			elif x > 1 and lmx[x - 2] == lmx[x - 1] and (aa[x - 1] == lmx[x - 1]):
				x -= 1
			else:
				z -= 1
		elif lmx[x - 1] > rmx[z - 1]:
			x -= 1
		else:
			z -= 1
		cmn = min(cmn, aa[x], aa[n - z - 1])
	print('NO')

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


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
from itertools import permutations, combinations

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 = 998244353

class SegmentTree:

	def __init__(self, data, default=INF, func=min):
		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
		while idx:
			idx >>= 1
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])

	def __len__(self):
		return self._len

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

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
for t in range(int(data())):
	n = int(data())
	a = mdata()
	S = SegmentTree(a)
	m = [[a[-1], 1]]
	d = dd(int)
	d[a[-1]] = n - 1
	for i in range(n - 2, -1, -1):
		if a[i] <= m[-1][0]:
			m.append(m[-1])
			if a[i] == m[-1][0]:
				m[-1][1] += 1
			d[m[-1][0]] = i
		else:
			m.append([a[i], 1])
			d[a[i]] = i
	m = m[::-1]
	m1 = a[0]
	flag = False
	l = []
	if m[0][1] > 2:
		flag = True
		l = []
		for i in range(n):
			if len(l) == 3:
				break
			if a[i] == m[0][0]:
				l.append(i + 1)
		(l[0], l[1], l[2]) = (l[1] - 1, 1, n - l[1])
	else:
		for i in range(n):
			m1 = max(m1, a[i])
			if m1 in d and d[m1] > i:
				m2 = S.query(i + 1, d[m1])
				if m2 == m1:
					flag = True
					l = [i + 1, d[m1] - i - 1, n - d[m1]]
				elif m2 > m1 and a[d[m1]] == m1 and (m[d[m1]][1] > 1):
					l = [i + 1, d[m1] - i, n - d[m1] - 1]
					flag = True
			if flag:
				break
	if flag:
		out('YES')
		outl(l)
	else:
		out('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt
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

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 testcase(t):
	for pp in range(t):
		solve(pp)

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

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

def power(x, y, p):
	y %= p - 1
	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
inf = pow(10, 20)
mod = 10 ** 9 + 7

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

def solve(case):
	n = int(inp())
	a = lis()
	rmq = RangeQuery(a)
	mxleft = [a[0]] * n
	curr = a[0]
	for i in range(1, n):
		curr = max(curr, a[i])
		mxleft[i] = curr
	mxright = [a[n - 1]] * n
	curr = a[n - 1]
	for i in range(n - 2, -1, -1):
		curr = max(a[i], curr)
		mxright[i] = curr
	for i in range(n):
		lo = i + 1
		hi = n - 2
		ans = mxleft[i]
		while lo <= hi:
			mid = (lo + hi) // 2
			chcker = rmq.query(i + 1, mid + 1)
			if mxright[mid + 1] < ans:
				hi = mid - 1
			elif mxright[mid + 1] > ans:
				lo = mid + 1
			elif mxright[mid + 1] == ans:
				if chcker > ans:
					lo = mid + 1
				elif chcker < ans:
					hi = mid - 1
				elif chcker == ans:
					print('YES')
					print(i + 1, mid - i, n - mid - 1)
					return
	print('NO')
	sys.stdout.flush()
testcase(int(inp()))


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
T = Tp.TypeVar('T')

class SegmentTree(Tp.Generic[T]):
	__slots__ = ['size', 'tree', 'identity', 'op', 'update_op']

	def __init__(self, size: int, identity: T, op: Tp.Callable[[T, T], T], update_op: Tp.Callable[[T, T], T]) -> None:
		self.size = size
		self.tree = [identity] * (size * 2)
		self.identity = identity
		self.op = op
		self.update_op = update_op

	def build(self, a: Tp.List[T]) -> None:
		tree = self.tree
		tree[self.size:self.size + len(a)] = a
		for i in range(self.size - 1, 0, -1):
			tree[i] = self.op(tree[i << 1], tree[(i << 1) + 1])

	def find(self, left: int, right: int) -> T:
		left += self.size
		right += self.size
		(tree, result, op) = (self.tree, self.identity, self.op)
		while left < right:
			if left & 1:
				result = op(tree[left], result)
				left += 1
			if right & 1:
				result = op(tree[right - 1], result)
			(left, right) = (left >> 1, right >> 1)
		return result

	def update(self, i: int, value: T) -> None:
		(op, tree) = (self.op, self.tree)
		i = self.size + i
		tree[i] = self.update_op(tree[i], value)
		while i > 1:
			i >>= 1
			tree[i] = op(tree[i << 1], tree[(i << 1) + 1])

def main():
	from collections import defaultdict
	t = int(input())
	ans = ['NO'] * t
	for ti in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		segtree = SegmentTree[int](n, 10 ** 9 + 1, min, min)
		segtree.build(a)
		right_max = [0] * (n + 1)
		r_max_i = defaultdict(list)
		for i in range(n - 1, -1, -1):
			right_max[i] = max(right_max[i + 1], a[i])
			r_max_i[right_max[i]].append(i)
		left_max = 0
		for i in range(n - 2):
			left_max = max(left_max, a[i])
			while r_max_i[left_max] and r_max_i[left_max][-1] <= i:
				r_max_i[left_max].pop()
			if not r_max_i[left_max]:
				continue
			(ok, ng) = (i + 2, r_max_i[left_max][0] + 1)
			while abs(ok - ng) > 1:
				mid = ok + ng >> 1
				if segtree.find(i + 1, mid) >= left_max:
					ok = mid
				else:
					ng = mid
			if right_max[ok] == left_max and segtree.find(i + 1, ok) == left_max:
				ans[ti] = f'YES\n{i + 1} {ok - i - 1} {n - ok}'
				break
	sys.stdout.buffer.write(('\n'.join(ans) + '\n').encode('utf-8'))
main()


import sys
input = sys.stdin.buffer.readline
import math

class RMQMIN:

	def __init__(self, arr):
		self.arr = arr
		MAXN = len(arr)
		K = int(math.log2(MAXN)) + 1
		self.lookup = [[0 for _ in range(K + 1)] for __ in range(MAXN)]
		self.buildSparseTable()

	def buildSparseTable(self):
		n = len(self.arr)
		for i in range(0, n):
			self.lookup[i][0] = self.arr[i]
		j = 1
		while 1 << j <= n:
			i = 0
			while i + (1 << j) - 1 < n:
				if self.lookup[i][j - 1] < self.lookup[i + (1 << j - 1)][j - 1]:
					self.lookup[i][j] = self.lookup[i][j - 1]
				else:
					self.lookup[i][j] = self.lookup[i + (1 << j - 1)][j - 1]
				i += 1
			j += 1

	def query(self, L, R):
		R -= 1
		j = int(math.log2(R - L + 1))
		if self.lookup[L][j] <= self.lookup[R - (1 << j) + 1][j]:
			return self.lookup[L][j]
		else:
			return self.lookup[R - (1 << j) + 1][j]

def min2(l, r):
	return rmq.query(l, r + 1)
from collections import defaultdict as d
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	rmq = RMQMIN(a)
	indexes = d(lambda : [])
	leftMax = [0 for _ in range(n)]
	for (i, x) in enumerate(a):
		indexes[x].append(i)
		leftMax[i] = x
		if i > 0:
			leftMax[i] = max(leftMax[i], leftMax[i - 1])
	rightMax = [0 for _ in range(n)]
	for i in range(n - 1, -1, -1):
		rightMax[i] = a[i]
		if i + 1 < n:
			rightMax[i] = max(rightMax[i], rightMax[i + 1])
	found = False
	for l in range(n - 2):
		val = leftMax[l]
		i = 0
		b = n
		while b > 0:
			while i + b < n and rightMax[i + b] > val:
				i += b
			b //= 2
		r1 = i + 1
		if r1 == n or rightMax[r1] != val:
			continue
		temp = indexes[val]
		i = 0
		b = len(temp)
		while b > 0:
			while b + i < len(temp) and temp[b + i] <= l:
				i += b
			b //= 2
		if i + 1 < len(temp) and a[temp[i + 1]] == val:
			nearestNextIdx = temp[i + 1]
			r = max(nearestNextIdx + 1, r1)
			if r < n and min2(l + 1, r - 1) == val and (rightMax[r] == val):
				x = l + 1
				y = r - x
				z = n - x - y
				found = True
				break
	if found:
		print('YES')
		print('{} {} {}'.format(x, y, z))
	else:
		print('NO')


from math import inf

def compute_prefix_max(seq):
	if not seq:
		return []
	result = [seq[0]] * len(seq)
	for i in range(1, len(seq)):
		new_max = seq[i]
		if new_max < result[i - 1]:
			new_max = result[i - 1]
		result[i] = new_max
	return result

def init_seg_tree_for_min(seq):
	seq = list(seq)
	seq_size = len(seq)
	seq_extended_size = 1
	while seq_extended_size < seq_size:
		seq_extended_size *= 2
	seq.extend([inf] * (seq_extended_size - seq_size))
	seg_tree = [None] * (len(seq) - 1) + seq
	for i_node in reversed(range(len(seq) - 1)):
		seg_tree[i_node] = min(seg_tree[i_node * 2 + 1], seg_tree[i_node * 2 + 2])
	return seg_tree

def min_on_seg(l, r, seg_tree):
	l += len(seg_tree) // 2
	r += len(seg_tree) // 2
	result = seg_tree[l]
	while l <= r:
		if l & 1 == 0:
			if seg_tree[l] < result:
				result = seg_tree[l]
		l = l >> 1
		if r & 1 == 1:
			if seg_tree[r] < result:
				result = seg_tree[r]
		r = (r >> 1) - 1
	return result

def read_ints():
	return map(int, input().split())
(t,) = read_ints()
for i_t in range(t):
	(n,) = read_ints()
	a_seq = tuple(read_ints())
	prefix_max = compute_prefix_max(a_seq)
	prefix_max_rev = compute_prefix_max(a_seq[::-1])[::-1]
	seg_tree_min = init_seg_tree_for_min(a_seq)
	for x in range(1, n - 2 + 1):
		value_need = prefix_max[x - 1]
		min_y = 1
		max_y = n - x - 1
		while min_y < max_y:
			mid_y = (min_y + max_y) // 2
			if prefix_max_rev[x + mid_y] < value_need:
				max_y = mid_y - 1
			elif prefix_max_rev[x + mid_y] > value_need:
				min_y = mid_y + 1
			else:
				val = min_on_seg(x, x + mid_y - 1, seg_tree_min)
				if val > value_need:
					min_y = mid_y + 1
				elif val < value_need:
					max_y = mid_y - 1
				else:
					y = mid_y
					break
		else:
			y = min_y
		if prefix_max_rev[x + y] == value_need and min_on_seg(x, x + y - 1, seg_tree_min) == value_need:
			print('YES')
			z = n - (x + y)
			print(x, y, z)
			break
	else:
		print('NO')


import sys
from sys import stdin

class SegTree:

	def __init__(self, N, first):
		self.NO = 2 ** (N - 1).bit_length()
		self.First = first
		self.data = [first] * (2 * self.NO)

	def calc(self, l, r):
		return min(l, r)

	def update(self, ind, x):
		ind += self.NO - 1
		self.data[ind] = x
		while ind >= 0:
			ind = (ind - 1) // 2
			self.data[ind] = self.calc(self.data[2 * ind + 1], self.data[2 * ind + 2])

	def query(self, l, r):
		L = l + self.NO
		R = r + self.NO
		s = self.First
		while L < R:
			if R & 1:
				R -= 1
				s = self.calc(s, self.data[R - 1])
			if L & 1:
				s = self.calc(s, self.data[L - 1])
				L += 1
			L >>= 1
			R >>= 1
		return s

	def get(self, ind):
		ind += self.NO - 1
		return self.data[ind]
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	lmax = [float('-inf')]
	for i in range(n - 1):
		lmax.append(max(lmax[-1], a[i]))
	rmax = [float('-inf')]
	for i in range(n - 2, -1, -1):
		rmax.append(max(rmax[-1], a[i]))
	rmax.reverse()
	ST = SegTree(n, float('inf'))
	for i in range(n):
		ST.update(i, a[i])
	dic = {}
	lis = []
	for i in a:
		if i not in dic:
			dic[i] = 0
		dic[i] += 1
		if dic[i] == 3:
			lis.append(i)
	lis.sort()
	lind = 0
	rind = n - 1
	for X in lis:
		LX = 0
		RX = 0
		while lind < n and a[lind] <= X:
			if a[lind] == X:
				LX += 1
			lind += 1
		while rind >= 0 and a[rind] <= X:
			if a[rind] == X:
				RX += 1
			rind -= 1
		if lind > rind:
			for i in range(1, n - 1):
				if a[i] == lmax[i] == rmax[i] == X:
					print('YES')
					print(i, 1, n - i - 1)
					break
			else:
				print('NO')
			break
		mmin = ST.query(lind, rind + 1)
		if mmin < X or LX == 0 or RX == 0:
			continue
		elif mmin == X:
			print('YES')
			print(lind, rind - lind + 1, n - rind - 1)
			break
		elif LX >= 2 and a[lind - 1] == X:
			print('YES')
			print(lind - 1, rind - lind + 2, n - rind - 1)
			break
		elif RX >= 2 and a[rind + 1] == X:
			print('YES')
			print(lind, rind - lind + 2, n - rind - 2)
			break
	else:
		print('NO')


from __future__ import division, print_function
from bisect import bisect_left as bl

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 testcase(t):
	for pp in range(t):
		solve(pp)
import sys
from math import ceil, log2
INT_MAX = sys.maxsize

def minVal(x, y):
	return x if x < y else y

def getMid(s, e):
	return s + (e - s) // 2

def RMQUtil(st, ss, se, qs, qe, index):
	if qs <= ss and qe >= se:
		return st[index]
	if se < qs or ss > qe:
		return INT_MAX
	mid = getMid(ss, se)
	return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2))

def RMQ(st, n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input')
		return -1
	return RMQUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2))
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * int(2 ** x) - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st

def solve(case):
	n = int(inp())
	a = lis()
	st = constructST(a, n)
	mxleft = [a[0]] * n
	curr = a[0]
	for i in range(1, n):
		curr = max(curr, a[i])
		mxleft[i] = curr
	mxright = [a[n - 1]] * n
	curr = a[n - 1]
	for i in range(n - 2, -1, -1):
		curr = max(a[i], curr)
		mxright[i] = curr
	mx = {}
	for i in range(n - 1, -1, -1):
		if mxright[i] in mx:
			mx[mxright[i]].append(i)
		else:
			mx[mxright[i]] = [i]
	for i in mx:
		mx[i] = mx[i][::-1]
	for i in range(n - 2):
		if mxleft[i] not in mx:
			continue
		ans = mxleft[i]
		lo = bl(mx[ans], i + 2)
		if lo < len(mx[ans]) and mx[ans][lo] > i + 1 and (RMQ(st, n, i + 1, mx[ans][lo] - 1) == ans):
			print('YES')
			print(i + 1, mx[ans][lo] - 1 - i, n - mx[ans][lo])
			return
		if lo < len(mx[ans]) - 1 and mx[ans][lo + 1] > i + 1 and (RMQ(st, n, i + 1, mx[ans][lo + 1] - 1) == ans):
			print('YES')
			print(i + 1, mx[ans][lo + 1] - 1 - i, n - mx[ans][lo + 1])
			return
	print('NO')
testcase(int(inp()))


import sys
import math
from collections import defaultdict, Counter
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 ceil, log2
INT_MAX = sys.maxsize

def minVal(x, y):
	return x if x < y else y

def getMid(s, e):
	return s + (e - s) // 2

def RMQUtil(st, ss, se, qs, qe, index):
	if qs <= ss and qe >= se:
		return st[index]
	if se < qs or ss > qe:
		return INT_MAX
	mid = getMid(ss, se)
	return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2))

def RMQ(st, n, qs, qe):
	return RMQUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2))
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * 2 ** x - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	st = constructST(a, n)
	d = defaultdict(list)
	ma = 0
	near = defaultdict(list)
	for j in range(n - 1, -1, -1):
		ma = max(ma, a[j])
		d[ma].append(j)
		near[a[j]].append(j)
	ma = 0
	for j in range(n - 2):
		ma = max(ma, a[j])
		while near[ma] and near[ma][-1] <= j:
			near[ma].pop()
		if near[ma]:
			while d[ma] and d[ma][-1] <= near[ma][-1]:
				d[ma].pop()
			if d[ma]:
				mi = RMQ(st, n, j + 1, d[ma][-1] - 1)
				if mi == ma:
					print('YES')
					print(j + 1, d[ma][-1] - j - 1, n - d[ma][-1])
					break
	else:
		print('NO')


import sys
input = sys.stdin.readline
import bisect
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	LEN = len(A)
	Sparse_table = [A]
	for i in range(LEN.bit_length() - 1):
		j = 1 << i
		B = []
		for k in range(len(Sparse_table[-1]) - j):
			B.append(min(Sparse_table[-1][k], Sparse_table[-1][k + j]))
		Sparse_table.append(B)

	def query(l, r):
		i = (r - l).bit_length() - 1
		return min(Sparse_table[i][l], Sparse_table[i][r - (1 << i)])
	LMAX = [A[0]]
	for i in range(1, n):
		LMAX.append(max(LMAX[-1], A[i]))
	RMAX = A[-1]
	for i in range(n - 1, -1, -1):
		RMAX = max(RMAX, A[i])
		x = bisect.bisect(LMAX, RMAX)
		if x == 0:
			continue
		v = min(x, i - 1)
		if v <= 0:
			continue
		if LMAX[v - 1] == query(v, i) == RMAX:
			print('YES')
			print(v, i - v, n - i)
			break
		v -= 1
		if v <= 0:
			continue
		if LMAX[v - 1] == query(v, i) == RMAX:
			print('YES')
			print(v, i - v, n - i)
			break
	else:
		print('NO')


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

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

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

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

def print_list(l):
	print(' '.join(map(str, l)))

def sparse_table(a):
	n = len(a)
	table = [a]
	k = 0
	while n > 1 << k + 1:
		this = [0] * (n - (1 << k + 1) + 1)
		for i in range(n - (1 << k + 1) + 1):
			this[i] = min(table[-1][i], table[-1][i + (1 << k)])
		table.append(this)
		k += 1
	return table

def get_range_minimal(table, i, j):
	(k, t) = (0, j - i - 1 >> 1)
	while t:
		t >>= 1
		k += 1
	return min(table[k][i], table[k][j - (1 << k)])
for _ in range(N()):
	n = N()
	a = RLL()
	m = max(a)
	if a.count(m) > 2:
		key = a.index(m)
		key = a.index(m, key + 1)
		print('YES')
		print(key, 1, n - key - 1)
	else:
		table = sparse_table(a)
		flag = False
		(l, r, ml, mr) = (0, n, 0, 0)
		while ml < m:
			if a[l] == ml:
				ml = a[l + 1]
				l += 2
			else:
				ml = a[l]
				l += 1
			if a[r - 1] == mr:
				mr = a[r - 2]
				r -= 2
			else:
				mr = a[r - 1]
				r -= 1
			while ml != mr:
				while ml < mr:
					ml = max(ml, a[l])
					l += 1
				while mr < ml:
					r -= 1
					mr = max(mr, a[r])
			if ml == m:
				break
			for i in range(l, r):
				if a[i] > ml:
					break
				l = i + (a[i] < ml)
			for i in range(r - 1, l - 1, -1):
				if a[i] > mr:
					break
				r = i + (a[i] == mr)
			if l < r and get_range_minimal(table, l, r) == ml:
				print('YES')
				print(l, r - l, n - r)
				flag = True
				break
		if not flag:
			print('NO')


from math import log2, ceil

def build(cur, l, r):
	if l == r:
		segTree[cur] = arr[l]
		return arr[l]
	mid = l + (r - l) // 2
	segTree[cur] = min(build(2 * cur + 1, l, mid), build(2 * cur + 2, mid + 1, r))
	return segTree[cur]

def query(cur, sl, sr, l, r):
	if l <= sl and r >= sr:
		return segTree[cur]
	elif l > sr or r < sl:
		return float('inf')
	else:
		mid = sl + (sr - sl) // 2
		return min(query(cur * 2 + 1, sl, mid, l, r), query(cur * 2 + 2, mid + 1, sr, l, r))

def helper(n):
	r = n - 1
	for l in range(n - 2):
		left = maxl[l]
		while r > l + 1 and maxr[n - 1 - r] <= left:
			r -= 1
		if r < n - 1:
			r += 1
		if left == maxr[n - 1 - r]:
			midMin = query(0, 0, n - 1, l + 1, r - 1)
			if left == midMin:
				return [l + 1, r - l - 1, n - r]
			elif midMin < left:
				pass
			elif r < n - 1:
				r += 1
				if left == maxr[n - 1 - r] and query(0, 0, n - 1, l + 1, r - 1) == left:
					return [l + 1, r - l - 1, n - r]
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(maxl, maxr) = ([arr[0]], [arr[-1]])
	for i in range(1, n):
		maxl.append(max(maxl[-1], arr[i]))
		maxr.append(max(maxr[-1], arr[-(i + 1)]))
	size = 2 ** (ceil(log2(n)) + 1) - 1
	segTree = [float('inf') for i in range(size)]
	build(0, 0, n - 1)
	ans = helper(n)
	if not ans:
		print('NO')
	else:
		print('YES')
		print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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 SegmentTree:

	def __init__(self, data, default=10 ** 10, 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)
MOD = 10 ** 9 + 7

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
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pre = [a[0]] * n
	post = [a[-1]] * n
	for i in range(1, n):
		pre[i] = max(pre[i - 1], a[i])
	for i in range(n - 2, -1, -1):
		post[i] = max(post[i + 1], a[i])
	s = SegmentTree(a)
	j = n - 1
	ch = 0
	for i in range(n - 2):
		j = max(j, i + 2)
		while j > i + 1 and post[j] <= pre[i]:
			if post[j - 1] > pre[i]:
				break
			j -= 1
		if post[j] != pre[i]:
			continue
		if s.query(i + 1, j - 1) < pre[i]:
			continue
		elif s.query(i + 1, j - 1) == pre[i]:
			print('YES')
			print(i + 1, j - i - 1, n - j)
			ch = 1
			break
		elif i != 0 and pre[i - 1] == s.query(i, j - 1) == post[j]:
			print('YES')
			print(i, j - i, n - j)
			ch = 1
			break
		elif j != n - 1 and pre[i] == post[j + 1] == s.query(i + 1, j):
			print('YES')
			print(i + 1, j - i, n - j - 1)
			ch = 1
			break
	if ch == 0:
		print('NO')


from sys import stdin, stdout
from math import log, ceil

def array_partition(n, a_a):
	lm = [a_a[0]]
	rm = [a_a[-1]]
	for i in range(1, n):
		lm.append(max(lm[-1], a_a[i]))
		rm.append(max(rm[-1], a_a[-(i + 1)]))
	r = n - 1
	for l in range(n - 2):
		left = lm[l]
		while r > l + 1 and rm[n - 1 - r] <= left:
			r -= 1
		if r < n - 1:
			r += 1
		if left == rm[n - 1 - r]:
			mm = query(0, 0, n - 1, l + 1, r - 1)
			if left == mm:
				return [l + 1, r - l - 1, n - r]
			elif mm < left:
				pass
			elif r < n - 1:
				r += 1
				if left == rm[n - 1 - r] and query(0, 0, n - 1, l + 1, r - 1) == left:
					return [l + 1, r - l - 1, n - r]
	return []

def build(cur, l, r):
	if l == r:
		segTree[cur] = a_a[l]
		return a_a[l]
	mid = l + (r - l) // 2
	segTree[cur] = min(build(2 * cur + 1, l, mid), build(2 * cur + 2, mid + 1, r))
	return segTree[cur]

def query(cur, sl, sr, l, r):
	if l <= sl and r >= sr:
		return segTree[cur]
	elif l > sr or r < sl:
		return float('inf')
	else:
		mid = sl + (sr - sl) // 2
		return min(query(cur * 2 + 1, sl, mid, l, r), query(cur * 2 + 2, mid + 1, sr, l, r))
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a_a = list(map(int, stdin.readline().split()))
	size = int(2 ** (ceil(log(n, 2)) + 1) - 1)
	segTree = [float('inf') for i in range(size)]
	build(0, 0, n - 1)
	r = array_partition(n, a_a)
	if r:
		stdout.write('YES\n')
		stdout.write(' '.join(map(str, r)) + '\n')
	else:
		stdout.write('NO\n')


import os, sys
from io import BytesIO, IOBase
from collections import defaultdict
from bisect import bisect_left as bisect
from math import inf

def cons(n, x):
	xx = n.bit_length()
	dp = [[inf] * n for _ in range(xx)]
	dp[0] = x
	for i in range(1, xx):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def ask(l, r, dp):
	xx1 = (r - l + 1).bit_length() - 1
	return min(dp[xx1][l], dp[xx1][r - (1 << xx1) + 1])

def solve(dct, dct1, dp, suff, n, a):
	maxi = 0
	for i in range(n):
		maxi = max(maxi, a[i])
		y = dct[maxi]
		if dct1.get(maxi):
			x = bisect(y, i + 1)
			if x != len(y):
				z = max(y[x], dct1[maxi])
				if z != n - 1 and ask(i + 1, z, dp) == maxi and (suff[z + 1] == maxi):
					return (i + 1, z - i, n - z - 1)
	return 'NO'

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		dct = defaultdict(list)
		dp = cons(n, a)
		for (ind, i) in enumerate(a):
			dct[i].append(ind)
		suff = [a[-1]]
		for i in range(n - 2, -1, -1):
			suff.append(max(suff[-1], a[i]))
		suff.reverse()
		dct1 = {}
		for i in range(n - 2, -1, -1):
			if suff[i] != suff[i + 1]:
				dct1[suff[i + 1]] = i
		dct1[suff[0]] = -1
		x = solve(dct, dct1, dp, suff, n, a)
		if x == 'NO':
			print(x)
		else:
			print('YES')
			print(*x)
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
input = sys.stdin.readline

def format(a, b=0, n=0):
	if a == -1:
		return 'NO'
	else:
		return 'YES\n{} {} {}'.format(a, b - a, n - b)

def solve():
	n = int(input())
	ar = [int(t) for t in input().split()]
	rmq = RangeQuery(ar)
	fmax = max(ar)
	idxs = [i for i in range(n) if ar[i] == fmax]
	if len(idxs) >= 3:
		mid = idxs[1]
		return format(mid, mid + 1, n)
	front = []
	(cmax, event) = (0, 0)
	for i in range(n):
		x = ar[i]
		if x > cmax:
			front += [(cmax, event)]
			cmax = x
			event = i
		elif x < cmax:
			event = i
	back = []
	(cmax, event) = (0, n)
	for i in reversed(range(n)):
		x = ar[i]
		if x > cmax:
			back += [(cmax, event)]
			cmax = x
			event = i
		elif x < cmax:
			event = i
	fit = iter(front)
	bit = iter(back)
	f = next(fit, False)
	b = next(bit, False)
	while f and b:
		if f[0] == b[0]:
			if f[0] == rmq.query(f[1] + 1, b[1]):
				return format(f[1] + 1, b[1], n)
			else:
				f = next(fit, False)
				b = next(bit, False)
		elif f[0] < b[0]:
			f = next(fit, False)
		else:
			b = next(bit, False)
	return format(-1)

def main():
	T = int(input())
	ans = []
	for _ in range(T):
		ans += [solve()]
	print(*ans, sep='\n')

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

	def __getitem__(self, idx):
		return self._data[0][idx]
main()