#include<bits/stdc++.h>
using namespace std;
#define dd double
#define ll long long int
#define light ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif

	light;
	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll>a(n),pref(n),suff(n+1);
		for(auto &ele:a){
			cin>>ele;
		}
		pref[0]=a[0];
		suff[n]=0;
		for(ll i=1;i<n;i++){
			pref[i]=max(a[i],pref[i-1]);
		}
		for(ll i=n-1;i>=0;i--){
			suff[i]=max(a[i],suff[i+1]);
		}
		set<pair<ll,ll>>st;
		for(ll i=0;i<n;i++){
			st.insert({a[i],i});
		}
		ll r=n;
		bool ans=0;
		for(ll l=0;l<n-2;l++){
			if(r==l){
				break;
			}
			st.erase({a[l],l});
			while(r>l+1 && suff[r]<=pref[l]){
				st.erase({a[r],r});
				r--;
			}
			st.insert({a[r],r});
			r++;
			if(r==n||suff[r]<pref[l]){
				continue;
			}
			ll mini=st.begin()->first;
			if(mini==pref[l]){
				cout<<"YES\n";
				cout<<l+1<<" "<<r-l-1<<" "<<n-r<<"\n";
				ans=1;
				break;
			}
			if(mini>pref[l]){
				if((r<n-1) && (suff[r+1]==pref[l] && a[r+1]==pref[l])){
					cout<<"YES\n";
					cout<<l+1<<" "<<r-l<<" "<<n-r-1<<"\n";
					ans=1;
					break;
				}
			}
		}
		if(!ans){
			cout<<"NO\n";
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define dd double
#define ll long long int
#define light ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll INF=1e9+5;
ll mod=1e9+7; // Debugging,finding test case 721 . ha ha.

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	light
	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll>a(n);
		set<pair<ll,ll>>st;
		for(auto &ele:a){
			cin>>ele;
		}
		for(ll i=1;i<n-1;i++){
			st.insert({a[i],i});
		}
		ll l=0,r=n-1,m1=0,m2=0;
		bool ans=0;
		while(l+1<r){
			m1=max(m1,a[l]);
			m2=max(m2,a[r]);

			if(m1==m2){
				ll ele=st.begin()->first;
				if(ele==m1){
					cout<<"YES\n";
					cout<<l+1<<" "<<r-l-1<<" "<<n-r<<"\n";
					ans=1;
					break;
				}
				if(ele<m1){
					if(a[l+1]<=a[r-1]){
						l++;
						st.erase({a[l],l});
					}
					else{
						r--;
						st.erase({a[r],r});
					}
				}
				else{
					l++;
					r--;
					st.erase({a[l],l});
					st.erase({a[r],r});
				}
			}
			else if(m1<m2){
				l++;
				st.erase({a[l],l});
			}
			else{
				r--;
				st.erase({a[r],r});
			}
		}
		if(!ans){
			cout<<"NO\n";
		}
	}
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef int ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
//	freopen("name.in","r",stdin);
	read(t);
	log_[1]=0;
	for(re int i=1;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=log_[n];j++)
			for(re int i=1;i<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%d %d %d\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
	read(t);
	log_[1]=0;
	for(re int i=1;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		memset(maxn,0,sizeof(maxn));
		memset(minn,0,sizeof(minn));
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=log_[n];j++)
			for(re int i=1;i<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%d %lld %lld\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
	read(t);
	log_[1]=0;
	for(re int i=1;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		memset(maxn,0,sizeof(maxn));
		memset(minn,0,sizeof(minn));
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=20;j++)
			for(re int i=1;i+(1<<j)-1<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%d %lld %lld\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
	read(t);
	log_[1]=0;
	log_[2]=1;
	log_[3]=1;
	for(re int i=2;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=20;j++)
			for(re int i=1;i+(1<<j)-1<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%d %lld %lld\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
	read(t);
	log_[1]=0;
	log_[2]=1;
	log_[3]=1;
	for(re int i=2;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=20;j++)
			for(re int i=1;i+(1<<j)-1<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%lld %lld %lld\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


#include<bits/stdc++.h>
#define N 501001
#define re register
#define MAX 2001
#define inf 1e18
#define eps 1e-10
using namespace std;
typedef int ll;
typedef double db;
inline void read(re ll &ret)
{
    ret=0;re char c=getchar();re bool pd=false;
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
    ret=pd?-ret:ret;
    return;
}
ll t,n,a[N],log_[N],maxn[N][21],minn[N][21];
int main()
{
	freopen("name.in","r",stdin);
	read(t);
	log_[1]=0;
	for(re int i=1;(i<<1)<=200000;i++)
		log_[i<<1]=log_[(i<<1)|1]=log_[i]+1;
	while(t--)
	{
		read(n);
		for(re int i=1;i<=n;i++)
		{
			read(a[i]);
			maxn[i][0]=minn[i][0]=a[i];
		}
		for(re int j=1;j<=log_[n];j++)
			for(re int i=1;i<=n;i++)
				maxn[i][j]=max(maxn[i][j-1],maxn[i+(1<<j-1)][j-1]),
				minn[i][j]=min(minn[i][j-1],minn[i+(1<<j-1)][j-1]);
		re bool flag=false;
		for(re int i=1;i+1<n;i++)
		{
			re ll l=i+1,r=n-1,mid;
			re ll tmp=log_[i];
			re ll mx=max(maxn[1][tmp],maxn[i-(1<<tmp)+1][tmp]);
			re ll val1l,val1r,val2l,val2r;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn>=mx)
					l=mid+1,val1r=mid;
				else
					r=mid-1;
			}
			tmp=log_[val1r-i];
			re ll temp=min(minn[i+1][tmp],minn[val1r-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[mid-i];
				re ll mn=min(minn[i+1][tmp],minn[mid-(1<<tmp)+1][tmp]);
				if(mn<=mx)
					r=mid-1,val1l=mid;
				else
					l=mid+1;
			}
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx<=mx)
					r=mid-1,val2l=mid;
				else
					l=mid+1;
			}
			tmp=log_[n-val2l];
			temp=max(maxn[val2l+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
			if(temp!=mx)
				continue;
			l=i+1,r=n-1;
			while(l<=r)
			{
				mid=l+r>>1;
				tmp=log_[n-mid];
				re ll maxx=max(maxn[mid+1][tmp],maxn[n-(1<<tmp)+1][tmp]);
				if(maxx>=mx)
					l=mid+1,val2r=mid;
				else
					r=mid-1;
			}
		//	cout<<i<<" "<<val1l<<" "<<val2l<<endl;
			re ll ans1=max(val1l,val2l),ans2=min(val1r,val2r);
			if(ans1<=ans2)
			{
				puts("YES");
				printf("%d %d %d\n",i,ans1-i,n-ans1);
				flag=true;
				break;
			}
		}
		if(!flag)
			puts("NO");
	}
    exit(0);
}


/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
ifstream file("C:\\Users\\86180\\Desktop\\P4149_2.txt");
	file>>n>>m;*/
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define N 100010
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int a,b,c,n,m,T,x[N],y[N],z[N];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		int maxx=0;m=0;b=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&x[i]);
			if(x[i]>maxx)m=i,maxx=x[i],b=0;
			else if(x[i]==maxx)b++,m=i;
		}
		if(b>=2){
			m--;
			while(x[m]!=maxx)m--;
		}
		for(int i=1;i<=n+10;i++)y[i]=z[i]=0;
		for(int i=1;i<=n;i++)y[i]=max(y[i-1],x[i]);
		for(int i=n;i>0;i--)z[i]=max(z[i+1],x[i]);
		/*for(int i=1;i<=n;i++)cout<<z[i]<<' ';
		cout<<endl;*/
		int u,v,w,l=m,r=m;
		u=x[l];
		v=y[l-1];
		w=z[r+1];
		/*debug(u);
		debug(v);
		debug(w);*/
		while(1){
			if(u==v&&u==w)break;
			if(r==n-1&&l>2){
				u=min(u,x[l-1]),v=y[l-2];
					l--;
			}else if(l==2&&r<n-1){
					u=min(u,x[r+1]),w=z[r+2];
					r++;
			}else if(l>2&&r<n-1){
				int t1=min(min(u,x[r+1]),min(v,z[r+2])),t2=min(min(u,x[l-1]),min(y[l-2],w));
				if(t1>t2){
					u=min(u,x[r+1]),w=z[r+2];
					r++;
				}
				else{
					u=min(u,x[l-1]),v=y[l-2];
					l--;
				}
			}else break;

		}
		if(u==v&&u==w)cout<<"YES\n"<<l-1<<' '<<r-l+1<<' '<<n-r<<endl;
		else cout<<"NO\n";
	}
}


/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
ifstream file("C:\\Users\\86180\\Desktop\\P4149_2.txt");
	file>>n>>m;*/
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define N 200010
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int a,b,c,n,m,T,x[N],y[N],z[N];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		int maxx=0;m=0;b=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&x[i]);
			if(x[i]>maxx)m=i,maxx=x[i],b=0;
			else if(x[i]==maxx)b++,m=i;
		}
		if(b>=2){
			m--;
			while(x[m]!=maxx)m--;
		}
		for(int i=1;i<=n+10;i++)y[i]=z[i]=0;
		for(int i=1;i<=n;i++)y[i]=max(y[i-1],x[i]);
		for(int i=n;i>0;i--)z[i]=max(z[i+1],x[i]);
		/*for(int i=1;i<=n;i++)cout<<z[i]<<' ';
		cout<<endl;*/
		int u,v,w,l=m,r=m;
		u=x[l];
		v=y[l-1];
		w=z[r+1];
		/*debug(u);
		debug(v);
		debug(w);*/
		while(l>2&&r<n-1){
			if(u==v&&u==w)break;
			int t1=min(min(u,x[r+1]),min(v,z[r+2])),t2=min(min(u,x[l-1]),min(y[l-2],w));
			if(t1>t2){
				u=min(u,x[r+1]),w=z[r+2];
				r++;
			}
			else{
				u=min(u,x[l-1]),v=y[l-2];
				l--;
			}
		}
		if(u==v&&u==w)cout<<"YES\n"<<l-1<<' '<<r-l+1<<' '<<n-r<<endl;
		else cout<<"NO\n";
	}
}


/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
ifstream file("C:\\Users\\86180\\Desktop\\P4149_2.txt");
	file>>n>>m;*/
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define N 200010
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int a,b,c,n,m,T,x[N],y[N],z[N];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		int maxx=0;m=0;b=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&x[i]);
			if(x[i]>maxx)m=i,maxx=x[i],b=0;
			else if(x[i]==maxx)b++,m=i;
		}
		if(b>=2){
			m--;
			while(x[m]!=maxx)m--;
		}
		for(int i=1;i<=n+10;i++)y[i]=z[i]=0;
		for(int i=1;i<=n;i++)y[i]=max(y[i-1],x[i]);
		for(int i=n;i>0;i--)z[i]=max(z[i+1],x[i]);
		/*for(int i=1;i<=n;i++)cout<<z[i]<<' ';
		cout<<endl;*/
		int u,v,w,l=m,r=m;
		u=x[l];
		v=y[l-1];
		w=z[r+1];
		/*debug(u);
		debug(v);
		debug(w);*/
		while(1){
			if(u==v&&u==w)break;
			if(r==n-1&&l>2){
				u=min(u,x[l-1]),v=y[l-2];
					l--;
			}else if(l==2&&r<n-1){
					u=min(u,x[r+1]),w=z[r+2];
					r++;
			}else if(l>2&&r<n-1){
				int t1=min(min(u,x[r+1]),min(v,z[r+2])),t2=min(min(u,x[l-1]),min(y[l-2],w));
				if(t1>t2){
					u=min(u,x[r+1]),w=z[r+2];
					r++;
				}
				else{
					u=min(u,x[l-1]),v=y[l-2];
					l--;
				}
			}else break;

		}
		if(u==v&&u==w)cout<<"YES\n"<<l-1<<' '<<r-l+1<<' '<<n-r<<endl;
		else cout<<"NO\n";
	}
}


/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
ifstream file("C:\\Users\\86180\\Desktop\\P4149_2.txt");
	file>>n>>m;*/
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define N 100010
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int a,b,c,n,m,T,x[N],y[N],z[N];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		int maxx=0;m=0;b=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&x[i]);
			if(x[i]>maxx)m=i,maxx=x[i],b=0;
			else if(x[i]==maxx)b++,m=i;
		}
		if(b>=2){
			m--;
			while(x[m]!=maxx)m--;
		}
		for(int i=1;i<=n+10;i++)y[i]=z[i]=0;
		for(int i=1;i<=n;i++)y[i]=max(y[i-1],x[i]);
		for(int i=n;i>0;i--)z[i]=max(z[i+1],x[i]);
		/*for(int i=1;i<=n;i++)cout<<z[i]<<' ';
		cout<<endl;*/
		int u,v,w,l=m,r=m;
		u=x[l];
		v=y[l-1];
		w=z[r+1];
		/*debug(u);
		debug(v);
		debug(w);*/
		while(l>2&&r<n-1){
			if(u==v&&u==w)break;
			int t1=min(min(u,x[r+1]),min(v,z[r+2])),t2=min(min(u,x[l-1]),min(y[l-2],w));
			if(t1>t2){
				u=min(u,x[r+1]),w=z[r+2];
				r++;
			}
			else{
				u=min(u,x[l-1]),v=y[l-2];
				l--;
			}
		}
		if(u==v&&u==w)cout<<"YES\n"<<l-1<<' '<<r-l+1<<' '<<n-r<<endl;
		else cout<<"NO\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define PI pair<int,int>
const int maxm=2e5+5;
int lg2[maxm];
int a[maxm];
int n;
struct ST{
    int ma[maxm][25];
    int mi[maxm][25];
    const static int maxd=20;
    void init(){
        for(int i=1;i<=n;i++){
            ma[i][0]=a[i];
            mi[i][0]=a[i];
        }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                ma[i][j]=max(ma[i][j-1],ma[i+(1<<(j-1))][j-1]);
                mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int askma(int l,int r){
        int k=lg2[r-l+1];
        return max(ma[l][k],ma[r-(1<<k)+1][k]);
    }
    int askmi(int l,int r){
        int k=lg2[r-l+1];
        return min(mi[l][k],mi[r-(1<<k)+1][k]);
    }
}T;
void lg2_init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    T.init();
    for(int i=1;i<=n-2;i++){
        int temp=T.askma(1,i);
//        cout<<"---"<<endl;
        //二分出l1
        int l=i+1,r=n;
        int l1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)<=temp){
                l1=mid,r=mid-1;
            }else{
                l=mid+1;
            }
        }
//        cout<<"---"<<endl;
        if(l1==-1||T.askmi(i+1,l1)!=temp)continue;
        //二分出r1
        l=l1,r=n;
        int r1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askma(i+1,mid)==temp){
                r1=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        //check
        l=l1+1,r=r1;
        int pos=0;
        while(l<=r){
            int mid=(l+r)/2;
            int f=T.askma(mid,n);
            if(f==temp){
                pos=mid;
                break;
            }else if(f>temp){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        if(pos){
            cout<<"YES"<<endl;
            cout<<i<<' '<<pos-i+1<<' '<<n-pos<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    lg2_init();
    int TT;cin>>TT;
    while(TT--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define PI pair<int,int>
const int maxm=2e5+5;
int lg2[maxm];
int a[maxm];
int n;
struct ST{
    int ma[maxm][25];
    int mi[maxm][25];
    const static int maxd=20;
    void init(){
        for(int i=1;i<=n;i++){
            ma[i][0]=a[i];
            mi[i][0]=a[i];
        }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                ma[i][j]=max(ma[i][j-1],ma[i+(1<<(j-1))][j-1]);
                mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int askma(int l,int r){
        int k=lg2[r-l+1];
        return max(ma[l][k],ma[r-(1<<k)+1][k]);
    }
    int askmi(int l,int r){
        int k=lg2[r-l+1];
        return min(mi[l][k],mi[r-(1<<k)+1][k]);
    }
}T;
void lg2_init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    T.init();
    for(int i=1;i<=n-2;i++){
        int temp=T.askma(1,i);
        //二分出l1
        int l=i+1,r=n;
        int l1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)<=temp){
                l1=mid,r=mid-1;
            }else{
                l=mid+1;
            }
        }
        if(l1==-1||T.askmi(i+1,l1)!=temp)continue;
        //二分出r1
        l=l1,r=n;
        int r1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)==temp){
                r1=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        //check
        l=l1+1,r=min(r1+1,n);
        int pos=0;
        while(l<=r){
            int mid=(l+r)/2;
            int f=T.askma(mid,n);
            if(f==temp){
                pos=mid;
                break;
            }else if(f>temp){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        if(pos){
            cout<<"YES"<<endl;
            cout<<i<<' '<<pos-1-i<<' '<<n-pos+1<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    lg2_init();
    int TT;cin>>TT;
    while(TT--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxm=2e5+5;
int lg2[maxm];
int a[maxm];
int n;
struct ST{
    int ma[maxm][25];
    int mi[maxm][25];
    const static int maxd=20;
    void init(){
        for(int i=1;i<=n;i++){
            ma[i][0]=a[i];
            mi[i][0]=a[i];
        }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                ma[i][j]=max(ma[i][j-1],ma[i+(1<<(j-1))][j-1]);
                mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int askma(int l,int r){
        int k=lg2[r-l+1];
        return max(ma[l][k],ma[r-(1<<k)+1][k]);
    }
    int askmi(int l,int r){
        int k=lg2[r-l+1];
        return min(mi[l][k],mi[r-(1<<k)+1][k]);
    }
}T;
void lg2_init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    T.init();
    for(int i=1;i<=n-2;i++){
        int temp=T.askma(1,i);
        //二分出l1
        int l=i+1,r=n-1;
        int l1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)<=temp){
                l1=mid,r=mid-1;
            }else{
                l=mid+1;
            }
        }
        if(l1==-1||T.askmi(i+1,l1)!=temp)continue;
        //二分出r1
        l=l1,r=n-1;
        int r1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)==temp){
                r1=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        //check
        l=l1+1,r=min(r1+1,n);
        int pos=0;
        while(l<=r){
            int mid=(l+r)/2;
            int f=T.askma(mid,n);
            if(f==temp){
                pos=mid;
                break;
            }else if(f>temp){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        if(pos){
            cout<<"YES"<<endl;
            cout<<i<<' '<<pos-1-i<<' '<<n-pos+1<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    lg2_init();
    int TT;cin>>TT;
    while(TT--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define PI pair<int,int>
const int maxm=2e5+5;
int lg2[maxm];
int a[maxm];
int n;
struct ST{
    int ma[maxm][25];
    int mi[maxm][25];
    const static int maxd=20;
    void init(){
        for(int i=1;i<=n;i++){
            ma[i][0]=a[i];
            mi[i][0]=a[i];
        }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                ma[i][j]=max(ma[i][j-1],ma[i+(1<<(j-1))][j-1]);
                mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int askma(int l,int r){
        int k=lg2[r-l+1];
        return max(ma[l][k],ma[r-(1<<k)+1][k]);
    }
    int askmi(int l,int r){
        int k=lg2[r-l+1];
        return min(mi[l][k],mi[r-(1<<k)+1][k]);
    }
}T;
void lg2_init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    T.init();
    for(int i=1;i<=n-2;i++){
        int temp=T.askma(1,i);
        //二分出l1
        int l=i+1,r=n;
        int l1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)<=temp){
                l1=mid,r=mid-1;
            }else{
                l=mid+1;
            }
        }
        if(l1==-1||T.askmi(i+1,l1)!=temp)continue;
        //二分出r1
        l=l1,r=n;
        int r1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askma(i+1,mid)==temp){
                r1=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        //check
        l=l1+1,r=r1;
        int pos=0;
        while(l<=r){
            int mid=(l+r)/2;
            int f=T.askma(mid,n);
            if(f==temp){
                pos=mid;
                break;
            }else if(f>temp){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        if(pos){
            cout<<"YES"<<endl;
            cout<<i<<' '<<pos-i<<' '<<n-pos<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    lg2_init();
    int TT;cin>>TT;
    while(TT--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define PI pair<int,int>
const int maxm=2e5+5;
int lg2[maxm];
int a[maxm];
int n;
struct ST{
    int ma[maxm][25];
    int mi[maxm][25];
    const static int maxd=20;
    void init(){
        for(int i=1;i<=n;i++){
            ma[i][0]=a[i];
            mi[i][0]=a[i];
        }
        for(int j=1;j<=maxd;j++){
            for(int i=1;i+(1<<j)-1<=n;i++){
                ma[i][j]=max(ma[i][j-1],ma[i+(1<<(j-1))][j-1]);
                mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int askma(int l,int r){
        int k=lg2[r-l+1];
        return max(ma[l][k],ma[r-(1<<k)+1][k]);
    }
    int askmi(int l,int r){
        int k=lg2[r-l+1];
        return min(mi[l][k],mi[r-(1<<k)+1][k]);
    }
}T;
void lg2_init(){
    lg2[1]=0;
    for(int i=2;i<maxm;i++){
        lg2[i]=lg2[i-1];
        if((i&(i-1))==0)lg2[i]++;
    }
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    T.init();
    for(int i=1;i<=n-2;i++){
        int temp=T.askma(1,i);
        //二分出l1
        int l=i+1,r=n;
        int l1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)<=temp){
                l1=mid,r=mid-1;
            }else{
                l=mid+1;
            }
        }
        if(l1==-1||T.askmi(i+1,l1)!=temp)continue;
        //二分出r1
        l=l1,r=n;
        int r1=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(T.askmi(i+1,mid)==temp){
                r1=mid,l=mid+1;
            }else{
                r=mid-1;
            }
        }
        //check
        l=l1+1,r=r1;
        int pos=0;
        while(l<=r){
            int mid=(l+r)/2;
            int f=T.askma(mid,n);
            if(f==temp){
                pos=mid;
                break;
            }else if(f>temp){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        if(pos){
            cout<<"YES"<<endl;
            cout<<i<<' '<<pos-i<<' '<<n-pos<<endl;
            return ;
        }
    }
    cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    lg2_init();
    int TT;cin>>TT;
    while(TT--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int tc;

int n, a[200010], pm[200010], sm[200010];
int st[200010][110], Log[200010];

int ask(int l, int r) {
    int len = r - l + 1;
    return min(st[l][Log[len]], st[r - (1 << Log[len]) + 1][Log[len]]);
}

int main() {

    Log[1] = 0;
    Rep(i, 1, 200000) Log[i] = Log[i - 1] + (i >> (Log[i - 1] + 1));

    tc = read();

    while (tc--) {

        n = read();
        Rep(i, 1, n) a[i] = read();

        Rep(i, 1, n) st[i][0] = a[i];
        Rep(j, 1, 20) {
            Rep(i, 1, n) {
                if (i + (1 << j) - 1 > n) break;
                st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
            }
        }

        pm[1] = a[1];
        Rep(i, 2, n) pm[i] = max(pm[i - 1], a[i]);
        sm[n] = a[n];
        Dep(i, n - 1, 1) sm[i] = max(sm[i + 1], a[i]);
        /*
        Rep(i, 1, n) cout << pm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) cout << sm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) {
            cout << "i = " << i << endl;
            Rep(j, 0, 4) cout << st[i][j] << ' ';
            cout << endl;
        }
        */

        int lpos = 1, rpos = n;
        int aa = 0, b = 0, c = 0;
        while (lpos < rpos - 1 && !aa) {
            // cout << "LRPOS = " << lpos << ' ' << rpos << endl;
            if (pm[lpos] == sm[rpos]) {
                int now = pm[lpos];
                int llpos = lpos + 1, rrpos = rpos - 1;
                while (pm[llpos] == now && llpos < rrpos) ++llpos;
                if (llpos == rrpos && a[rrpos] <= now) {
                    int pos = 0;
                    Rep(i, lpos + 1, rpos - 1) {
                        if (a[i] == now) {pos = i; break;}
                    }
                    if (pos) aa = pos - 1, b = pos, c = n;
                    break;
                }
                while (sm[rrpos] == now && llpos < rrpos) --rrpos;
                // cout << "LLRRPOS = " << llpos << ' ' << rrpos << endl;
                int Min = ask(llpos, rrpos);
                // cout << "Min = " << Min << endl;
                if (Min < now) {lpos = llpos, rpos = rrpos; continue;}
                else if (Min == now) {lpos = llpos, rpos = rrpos; aa = llpos - 1, b = rrpos, c = n; continue;}
                else {
                    Rep(i, rrpos + 1, rpos - 1) {
                        if (ask(llpos, i) < now) break;
                        if (ask(llpos, i) == now) {aa = llpos - 1, b = i; c = n; break;}
                    }
                    Dep(i, llpos - 1, lpos + 1) {
                        // cout << "l r ask = " << i << ' ' << rrpos << ' ' << ask(i, rrpos) << endl;
                        if (ask(i, rrpos) < now) break;
                        if (ask(i, rrpos) == now) {aa = i, b = rrpos, c = n; break;}
                    }
                }
                lpos = llpos, rpos = rrpos;
            }
            else if (pm[lpos] < sm[rpos]) ++lpos;
            else --rpos;
        }

        if (!aa) puts("NO");
        else puts("YES"), printf("%d %d %d\n", aa, b - aa, c - b);

    }

    // system("pause");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int tc;

int n, a[200010], pm[200010], sm[200010];
int st[200010][110], Log[200010];

int ask(int l, int r) {
    int len = r - l + 1;
    return min(st[l][Log[len]], st[r - (1 << Log[len]) + 1][Log[len]]);
}

int main() {

    Log[1] = 0;
    Rep(i, 1, 200000) Log[i] = Log[i - 1] + (i >> (Log[i - 1] + 1));

    tc = read();

    while (tc--) {

        n = read();
        Rep(i, 1, n) a[i] = read();

        Rep(i, 1, n) st[i][0] = a[i];
        Rep(j, 1, 20) {
            Rep(i, 1, n) {
                if (i + (1 << j) - 1 > n) break;
                st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
            }
        }

        pm[1] = a[1];
        Rep(i, 2, n) pm[i] = max(pm[i - 1], a[i]);
        sm[n] = a[n];
        Dep(i, n - 1, 1) sm[i] = max(sm[i + 1], a[i]);
        /*
        Rep(i, 1, n) cout << pm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) cout << sm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) {
            cout << "i = " << i << endl;
            Rep(j, 0, 4) cout << st[i][j] << ' ';
            cout << endl;
        }
        */

        int lpos = 1, rpos = n;
        int aa = 0, b = 0, c = 0;
        while (lpos < rpos - 1 && !aa) {
            // cout << "LRPOS = " << lpos << ' ' << rpos << endl;
            if (pm[lpos] == sm[rpos]) {
                int now = pm[lpos];
                int llpos = lpos + 1, rrpos = rpos - 1;
                while (pm[llpos] == now && llpos < rrpos) ++llpos;
                if (llpos == rrpos && a[rrpos] <= now) {
                    int pos = 0;
                    Rep(i, lpos + 1, rpos - 1) {
                        if (a[i] == now) {pos = i; break;}
                    }
                    // cout << "pos = " << pos << endl;
                    if (pos) aa = pos - 1, b = pos, c = n;
                    break;
                }
                while (sm[rrpos] == now && llpos < rrpos) --rrpos;
                // cout << "LLRRPOS = " << llpos << ' ' << rrpos << endl;
                int Min = ask(llpos, rrpos);
                // cout << "Min = " << Min << endl;
                if (Min < now) {lpos = llpos, rpos = rrpos; continue;}
                else if (Min == now) {lpos = llpos, rpos = rrpos; aa = llpos - 1, b = rrpos, c = n; continue;}
                else {
                    Rep(i, rrpos + 1, rpos - 1) {
                        if (ask(llpos, i) < now) break;
                        if (ask(llpos, i) == now) {aa = llpos - 1, b = i; c = n; break;}
                    }
                    if (aa) break;
                    Dep(i, llpos - 1, lpos + 1) {
                        // cout << "l r ask = " << i << ' ' << rrpos << ' ' << ask(i, rrpos) << endl;
                        if (ask(i, rrpos) < now) break;
                        if (ask(i, rrpos) == now) {aa = i - 1, b = rrpos, c = n; break;}
                    }
                }
                lpos = llpos, rpos = rrpos;
            }
            else if (pm[lpos] < sm[rpos]) ++lpos;
            else --rpos;
        }

        if (!aa) puts("NO");
        else puts("YES"), printf("%d %d %d\n", aa, b - aa, c - b);

    }

    // system("pause");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int tc;

int n, a[200010], pm[200010], sm[200010];
int st[200010][110], Log[200010];

int ask(int l, int r) {
    int len = r - l + 1;
    return min(st[l][Log[len]], st[r - (1 << Log[len]) + 1][Log[len]]);
}

int main() {

    Log[1] = 0;
    Rep(i, 1, 200000) Log[i] = Log[i - 1] + (i >> (Log[i - 1] + 1));

    tc = read();

    while (tc--) {

        n = read();
        Rep(i, 1, n) a[i] = read();

        Rep(i, 1, n) st[i][0] = a[i];
        Rep(j, 1, 20) {
            Rep(i, 1, n) {
                if (i + (1 << j) - 1 > n) break;
                st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
            }
        }

        pm[1] = a[1];
        Rep(i, 2, n) pm[i] = max(pm[i - 1], a[i]);
        sm[n] = a[n];
        Dep(i, n - 1, 1) sm[i] = max(sm[i + 1], a[i]);
        /*
        Rep(i, 1, n) cout << pm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) cout << sm[i] << ' ';
        cout << endl;
        Rep(i, 1, n) {
            cout << "i = " << i << endl;
            Rep(j, 0, 4) cout << st[i][j] << ' ';
            cout << endl;
        }
        */

        int lpos = 1, rpos = n;
        int aa = 0, b = 0, c = 0;
        while (lpos < rpos + 1 && !aa) {
            // cout << "LRPOS = " << lpos << ' ' << rpos << endl;
            if (pm[lpos] == sm[rpos]) {
                int now = pm[lpos];
                int llpos = lpos + 1, rrpos = rpos - 1;
                while (pm[llpos] == now && llpos < rrpos) ++llpos;
                if (llpos == rrpos && a[rrpos] <= now) {
                    int pos = 0;
                    Rep(i, lpos + 1, rpos - 1) {
                        if (a[i] == now) {pos = i; break;}
                    }
                    if (pos) aa = pos - 1, b = pos, c = n;
                    break;
                }
                while (sm[rrpos] == now && llpos < rrpos) --rrpos;
                // cout << "LLRRPOS = " << llpos << ' ' << rrpos << endl;
                int Min = ask(llpos, rrpos);
                // cout << "Min = " << Min << endl;
                if (Min < now) {lpos = llpos, rpos = rrpos; continue;}
                else if (Min == now) {lpos = llpos, rpos = rrpos; aa = llpos - 1, b = rrpos, c = n; continue;}
                else {
                    Rep(i, rrpos + 1, rpos - 1) {
                        if (ask(llpos, i) < now) break;
                        if (ask(llpos, i) == now) {aa = llpos - 1, b = i; c = n; break;}
                    }
                    Dep(i, llpos - 1, lpos + 1) {
                        // cout << "l r ask = " << i << ' ' << rrpos << ' ' << ask(i, rrpos) << endl;
                        if (ask(i, rrpos) < now) break;
                        if (ask(i, rrpos) == now) {aa = i, b = rrpos, c = n; break;}
                    }
                }
                lpos = llpos, rpos = rrpos;
            }
            else if (pm[lpos] < sm[rpos]) ++lpos;
            else --rpos;
        }

        if (!aa) puts("NO");
        else puts("YES"), printf("%d %d %d\n", aa, b - aa, c - b);

    }

    // system("pause");
    return 0;
}


#include<bits/stdc++.h>
#define _I inline
#define _R register
#define ll long long
#define lowbit(i) i&(-i)
#define INF 0x3f3f3f3f
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define ull unsigned long long
#define eps 1e-4
#define mod 998244353
#define y1 yy1
char buf[1<<18],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
using namespace std;
_I int read(){
    int x=0;bool f=0;char ch=getchar();
    while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
    while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    f&&(x=-x);
    return x;
}
const int N=200005;
int t,n,flag,a[N],mn[N][19],mx[N][19],lg[N];
int askmn(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return min(mn[l][d],mn[r-(1<<d)+1][d]);
}
int askmx(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return max(mx[l][d],mx[r-(1<<d)+1][d]);
}
signed main(){
//	system("fc prime.out prime32.out");
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	lg[0]=-1;
	for(_R int i=1;i<=N-5;++i)lg[i]=lg[i>>1]+1;
	t=read();while(t--){
		n=read();flag=0;
		for(_R int i=1;i<=n;++i)memset(mn,0x3f),memset(mx,0);
		for(_R int i=1;i<=n;++i)mn[i][0]=mx[i][0]=a[i]=read();
		for(_R int j=1;j<=18;++j)for(_R int i=1;i+(1<<j)-1<=n;++i)mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]),mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
		for(_R int i=1,x,maxx,y;i<n;++i){
			maxx=askmx(1,i);x=i+1;y=INF;
			for(_R int j=18;j>=0;--j)if(min(y,mn[x][j])>=maxx&&x+(1<<j)<=n)y=min(y,mn[x][j]),x+=(1<<j)-1;
			if(y!=maxx)continue;
//			cout<<i<<" "<<maxx<<" "<<x<<"\n";
			int l=i+1,r=x,mid;
			while(l<r){
				mid=(l+r)>>1;
				if(askmn(i+1,mid)>maxx)l=mid+1;
				else r=mid;
			}
			r=x;
			if(r==n)--r;
			l++;r++;
			if(l>r||askmx(r,n)>maxx||askmx(l,n)<maxx)continue;

//			cout<<l<<" "<<r<<"\n";
			while(l<r){
				mid=(l+r)>>1;
				if(askmx(mid,n)>maxx)l=mid+1;
				else r=mid;
			}
			if(askmx(1,i)==askmn(i+1,l-1)&&askmn(i+1,l-1)==askmx(l,n)){puts("YES");printf("%d %d %d\n",i,l-1-i,n-l+1);flag=1;break;}
		}
		if(!flag)puts("NO");
	}
    return 0;
}
/*
1
9
2 1 4 2 4 3 3 1 2
*/


#include<bits/stdc++.h>
#define _I inline
#define _R register
#define ll long long
#define lowbit(i) i&(-i)
#define INF 0x3f3f3f3f
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define ull unsigned long long
#define eps 1e-4
#define mod 998244353
#define y1 yy1
char buf[1<<18],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
using namespace std;
_I int read(){
    int x=0;bool f=0;char ch=getchar();
    while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
    while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    f&&(x=-x);
    return x;
}
const int N=200005;
int t,n,flag,a[N],mn[N][19],mx[N][19],lg[N];
int askmn(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return min(mn[l][d],mn[r-(1<<d)+1][d]);
}
int askmx(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return max(mx[l][d],mx[r-(1<<d)+1][d]);
}
signed main(){
//	system("fc prime.out prime32.out");
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	lg[0]=-1;
	for(_R int i=1;i<=N-5;++i)lg[i]=lg[i>>1]+1;
	t=read();while(t--){
		n=read();flag=0;
		for(_R int i=1;i<=n;++i)memset(mn[i],0x3f),memset(mx[i],0);
		for(_R int i=1;i<=n;++i)mn[i][0]=mx[i][0]=a[i]=read();
		for(_R int j=1;j<=18;++j)for(_R int i=1;i+(1<<j)-1<=n;++i)mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]),mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
		for(_R int i=1,x,maxx,y;i<n;++i){
			maxx=askmx(1,i);x=i+1;y=INF;
			for(_R int j=18;j>=0;--j)if(min(y,mn[x][j])>=maxx&&x+(1<<j)<=n)y=min(y,mn[x][j]),x+=(1<<j)-1;
			if(y!=maxx)continue;
//			cout<<i<<" "<<maxx<<" "<<x<<"\n";
			int l=i+1,r=x,mid;
			while(l<r){
				mid=(l+r)>>1;
				if(askmn(i+1,mid)>maxx)l=mid+1;
				else r=mid;
			}
			r=x;
			if(r==n)--r;
			l++;r++;
			if(l>r||askmx(r,n)>maxx||askmx(l,n)<maxx)continue;

//			cout<<l<<" "<<r<<"\n";
			while(l<r){
				mid=(l+r)>>1;
				if(askmx(mid,n)>maxx)l=mid+1;
				else r=mid;
			}
			if(askmx(1,i)==askmn(i+1,l-1)&&askmn(i+1,l-1)==askmx(l,n)){puts("YES");printf("%d %d %d\n",i,l-1-i,n-l+1);flag=1;break;}
		}
		if(!flag)puts("NO");
	}
    return 0;
}
/*
1
9
2 1 4 2 4 3 3 1 2
*/


#include<bits/stdc++.h>
#define _I inline
#define _R register
#define ll long long
#define lowbit(i) i&(-i)
#define INF 0x3f3f3f3f
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define ull unsigned long long
#define eps 1e-4
#define mod 998244353
#define y1 yy1
char buf[1<<18],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
using namespace std;
_I int read(){
    int x=0;bool f=0;char ch=getchar();
    while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
    while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    f&&(x=-x);
    return x;
}
const int N=200005;
int t,n,flag,a[N],mn[N][19],mx[N][19],lg[N];
int askmn(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return min(mn[l][d],mn[r-(1<<d)+1][d]);
}
int askmx(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return max(mx[l][d],mx[r-(1<<d)+1][d]);
}
signed main(){
//	system("fc prime.out prime32.out");
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	lg[0]=-1;
	for(_R int i=1;i<=N-5;++i)lg[i]=lg[i>>1]+1;
	t=read();while(t--){
		n=read();flag=0;
		for(_R int i=1;i<=n;++i)memset(mn[i],0x3f),memset(mx[i],0);
		for(_R int i=1;i<=n;++i)mn[i][0]=mx[i][0]=a[i]=read();
		for(_R int j=1;j<=18;++j)for(_R int i=1;i+(1<<j)-1<=n;++i)mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]),mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
		for(_R int i=1,x,maxx,y;i<n;++i){
			maxx=askmx(1,i);x=i+1;y=INF;
			for(_R int j=18;j>=0;--j)if(min(y,mn[x][j])>=maxx&&x+(1<<j)-1<=n)y=min(y,mn[x][j]),x+=(1<<j)-1;
			if(y!=maxx)continue;
//			cout<<i<<" "<<maxx<<" "<<x<<"\n";
			int l=i+1,r=x,mid;
			while(l<r){
				mid=(l+r)>>1;
				if(askmn(i+1,mid)>maxx)l=mid+1;
				else r=mid;
			}
			r=x;
			if(r==n)--r;
			l++;r++;
			if(l>r||askmx(r,n)>maxx||askmx(l,n)<maxx)continue;
//			cout<<l<<" "<<r<<"\n";
			while(l<r){
				mid=(l+r)>>1;
				if(askmx(mid,n)>maxx)l=mid+1;
				else r=mid;
			}
			if(askmx(1,i)==askmn(i+1,l-1)&&askmn(i+1,l-1)==askmx(l,n)){puts("YES");printf("%d %d %d\n",i,l-1-i,n-l+1);flag=1;break;}
		}
		if(!flag)puts("NO");
	}
    return 0;
}
/*
1
11
1 2 5 4 2 2 4 3 4 2 1
*/


#include<bits/stdc++.h>
#define _I inline
#define _R register
#define ll long long
#define lowbit(i) i&(-i)
#define INF 0x3f3f3f3f
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define ull unsigned long long
#define eps 1e-4
#define mod 998244353
#define y1 yy1
char buf[1<<18],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<18,stdin),p1==p2)?EOF:*p1++)
using namespace std;
_I int read(){
    int x=0;bool f=0;char ch=getchar();
    while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
    while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    f&&(x=-x);
    return x;
}
const int N=200005;
int t,n,flag,a[N],mn[N][19],mx[N][19],lg[N];
int askmn(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return min(mn[l][d],mn[r-(1<<d)+1][d]);
}
int askmx(int l,int r){
	if(l>r)return -1;
	int d=lg[r-l+1];
	return max(mx[l][d],mx[r-(1<<d)+1][d]);
}
signed main(){
//	system("fc prime.out prime32.out");
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	lg[0]=-1;
	for(_R int i=1;i<=N-5;++i)lg[i]=lg[i>>1]+1;
	t=read();while(t--){
		n=read();flag=0;
		for(_R int i=1;i<=n;++i)memset(mn[i],0x3f),memset(mx[i],0);
		for(_R int i=1;i<=n;++i)mn[i][0]=mx[i][0]=a[i]=read();
		for(_R int j=1;j<=18;++j)for(_R int i=1;i+(1<<j)-1<=n;++i)mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]),mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
		for(_R int i=1,x,maxx,y;i<n;++i){
			maxx=askmx(1,i);x=i+1;y=INF;
			for(_R int j=18;j>=0;--j)if(min(y,mn[x][j])>=maxx&&x+(1<<j)-1<=n)y=min(y,mn[x][j]),x+=(1<<j);
			x--;
			if(y!=maxx)continue;
//			cout<<i<<" "<<maxx<<" "<<x<<"\n";
			int l=i+1,r=x,mid;
			while(l<r){
				mid=(l+r)>>1;
				if(askmn(i+1,mid)>maxx)l=mid+1;
				else r=mid;
			}
			r=x;
			if(r==n)--r;
			l++;r++;
			if(l>r||askmx(r,n)>maxx||askmx(l,n)<maxx)continue;
//			cout<<l<<" "<<r<<"\n";
			while(l<r){
				mid=(l+r)>>1;
				if(askmx(mid,n)>maxx)l=mid+1;
				else r=mid;
			}
			if(askmx(1,i)==askmn(i+1,l-1)&&askmn(i+1,l-1)==askmx(l,n)){puts("YES");printf("%d %d %d\n",i,l-1-i,n-l+1);flag=1;break;}
		}
		if(!flag)puts("NO");
	}
    return 0;
}
/*
1
11
1 2 2 4 2 3 4 3 1 2 9
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int maxl[maxn];
int maxr[maxn];
int maxr2[maxn];
int n;
struct node
{
	int l,r;
	int mini;
}tree[maxn<<2];
void pushup(int k){
	tree[k].mini=min(tree[k<<1].mini,tree[k<<1|1].mini);
}
void build(int k,int l,int r){
	tree[k].l=l;tree[k].r=r;
	if(l==r){
		tree[k].mini=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	pushup(k);
}
int query(int k,int l,int r){
	if(tree[k].r<l||tree[k].l>r){return 0x7f7f7f7f;}
	if(l<=tree[k].l&&r>=tree[k].r){
		return tree[k].mini;
	}
	int mid=(tree[k].l+tree[k].r)>>1;
	int ans=0x7f7f7f7f;
	if(mid>=l){
		ans=min(query(k<<1,l,r),ans);
	}
	if(mid<r){
		ans=min(query(k<<1|1,l,r),ans);
	}
	return ans;
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	maxr[n+1]=maxr[0]=0;
	for(int i=1;i<=n;++i){
		maxl[i]=max(maxl[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		maxr[i]=max(maxr[i+1],a[i]);
		maxr2[n+1-i]=maxr[i];
	}
	// for(int i=1;i<=n;++i){
	// 	cout<<maxr[i]<<" ";
	// }
	// cout<<"\n";
	build(1,1,n);
	for(int i=1;i+1<n;i++){
		int pos=lower_bound(maxr2+1,maxr2+1+n,maxl[i])-maxr2;
		pos=n+1-pos;
		// if(i==3){cout<<"$$"<<pos<<"\n";}
		if(!pos||pos<=i+1||maxr[pos]!=maxl[i]){continue;}
		while(maxr[pos]==maxl[i]&&pos>i+1){
			pos--;
		}
		pos++;
		// while(maxr[pos]==maxl[i]&&pos>i+1){
			if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-pos+1<<"\n";
				return ;
			}
		// }
	}
	cout<<"NO\n";

}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int Case;
	cin>>Case;
	while(Case--){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int maxl[maxn];
int maxr[maxn];
int maxr2[maxn];
int n;
struct node
{
	int l,r;
	int mini;
}tree[maxn<<2];
void pushup(int k){
	tree[k].mini=min(tree[k<<1].mini,tree[k<<1|1].mini);
}
void build(int k,int l,int r){
	tree[k].l=l;tree[k].r=r;
	if(l==r){
		tree[k].mini=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	pushup(k);
}
int query(int k,int l,int r){
	if(tree[k].r<l||tree[k].l>r){return 0x7f7f7f7f;}
	if(l<=tree[k].l&&r>=tree[k].r){
		return tree[k].mini;
	}
	int mid=(tree[k].l+tree[k].r)>>1;
	int ans=0x7f7f7f7f;
	if(mid>=l){
		ans=min(query(k<<1,l,r),ans);
	}
	if(mid<r){
		ans=min(query(k<<1|1,l,r),ans);
	}
	return ans;
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	maxr[n+1]=maxl[0]=0;
	for(int i=1;i<=n;++i){
		maxl[i]=max(maxl[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		maxr[i]=max(maxr[i+1],a[i]);
		maxr2[n+1-i]=maxr[i];
	}
	// for(int i=1;i<=n;++i){
	// 	cout<<maxr[i]<<" ";
	// }
	// cout<<"\n";
	build(1,1,n);
	for(int i=1;i+1<n;i++){
		int pos=lower_bound(maxr2+1,maxr2+1+n,maxl[i])-maxr2;
		pos=n+1-pos;
		// if(i==3){cout<<"$$"<<pos<<"\n";}
		if(pos<=i+1||maxr[pos]!=maxl[i]){continue;}
		while(maxr[pos]==maxl[i]&&pos>i+1){
			pos--;
		}
		pos++;
		// while(maxr[pos]==maxl[i]&&pos>i+1){
			if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-pos+1<<"\n";
				return ;
			}
		// }
		pos++;
		if(maxr[pos]==maxl[i]&&pos>i+1){
				if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-pos+1<<"\n";
				return ;
			}
		}
	}
	cout<<"NO\n";

}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int Case;
	cin>>Case;
	while(Case--){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int maxl[maxn];
int maxr[maxn];
int maxr2[maxn];
int n;
struct node
{
	int l,r;
	int mini;
}tree[maxn<<2];
void pushup(int k){
	tree[k].mini=min(tree[k<<1].mini,tree[k<<1|1].mini);
}
void build(int k,int l,int r){
	tree[k].l=l;tree[k].r=r;
	if(l==r){
		tree[k].mini=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	pushup(k);
}
int query(int k,int l,int r){
	if(tree[k].r<l||tree[k].l>r){return 0x7f7f7f7f;}
	if(l<=tree[k].l&&r>=tree[k].r){
		return tree[k].mini;
	}
	int mid=(tree[k].l+tree[k].r)>>1;
	int ans=0x7f7f7f7f;
	if(mid>=l){
		ans=min(query(k<<1,l,r),ans);
	}
	if(mid<r){
		ans=min(query(k<<1|1,l,r),ans);
	}
	return ans;
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	maxr[n+1]=maxl[0]=0;
	for(int i=1;i<=n;++i){
		maxl[i]=max(maxl[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		maxr[i]=max(maxr[i+1],a[i]);
		maxr2[n+1-i]=maxr[i];
	}
	// for(int i=1;i<=n;++i){
	// 	cout<<maxr[i]<<" ";
	// }
	// cout<<"\n";
	build(1,1,n);
	for(int i=1;i+1<n;i++){
		//n->i+1
		int pos=upper_bound(maxr2+1,maxr2+(n-i),maxl[i])-maxr2;
		// cout<<pos<<"\n";
		pos--;
		pos=n+1-pos;
		// if(i==3){cout<<"$$"<<pos<<"\n";}
		if(pos<=i+1||maxr[pos]!=maxl[i]){continue;}
		// while(maxr[pos]==maxl[i]&&pos>i+1){
			if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-pos+1<<"\n";
				return ;
			}
		// }
		pos++;
		if(maxr[pos]==maxl[i]&&pos>i+1){
				if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-pos+1<<"\n";
				return ;
			}
		}
	}
	cout<<"NO\n";

}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int Case;
	cin>>Case;
	while(Case--){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int maxl[maxn];
int maxr[maxn];
int maxr2[maxn];
int n;
struct node
{
	int l,r;
	int mini;
}tree[maxn<<2];
void pushup(int k){
	tree[k].mini=min(tree[k<<1].mini,tree[k<<1|1].mini);
}
void build(int k,int l,int r){
	tree[k].l=l;tree[k].r=r;
	if(l==r){
		tree[k].mini=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	pushup(k);
}
int query(int k,int l,int r){
	if(tree[k].r<l||tree[k].l>r){return 0x7f7f7f7f;}
	if(l<=tree[k].l&&r>=tree[k].r){
		return tree[k].mini;
	}
	int mid=(tree[k].l+tree[k].r)>>1;
	int ans=0x7f7f7f7f;
	if(mid>=l){
		ans=min(query(k<<1,l,r),ans);
	}
	if(mid<r){
		ans=min(query(k<<1|1,l,r),ans);
	}
	return ans;
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	maxr[n+1]=a[0]=a[n+1]=0;
	for(int i=1;i<=n;++i){
		maxl[i]=max(maxl[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		maxr[i]=max(maxr[i+1],a[i]);
		maxr2[n+1-i]=maxr[i];
	}
	// for(int i=1;i<=n;++i){
	// 	cout<<maxr[i]<<" ";
	// }
	// cout<<"\n";
	build(1,1,n);
	for(int i=1;i+1<n;i++){
		int pos=lower_bound(maxr2+1,maxr2+1+n,maxl[i])-maxr2;
		pos=n+1-pos;
		if(!pos||pos<=i+1){continue;}
		while(maxr[pos]==maxl[i]&&pos>i+1){
			// if(pos>=n){pos--;continue;}
			// int temp=query(1,i+1,pos-1);
			// cout<<"%"<<temp<<"\n";
			if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-i-(pos-i-1)<<"\n";
				return ;
			}
			pos--;
		}
	}
	cout<<"NO\n";

}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int Case;
	cin>>Case;
	while(Case--){
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int maxl[maxn];
int maxr[maxn];
int maxr2[maxn];
int n;
struct node
{
	int l,r;
	int mini;
}tree[maxn<<2];
void pushup(int k){
	tree[k].mini=min(tree[k<<1].mini,tree[k<<1|1].mini);
}
void build(int k,int l,int r){
	tree[k].l=l;tree[k].r=r;
	if(l==r){
		tree[k].mini=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	pushup(k);
}
int query(int k,int l,int r){
	if(tree[k].r<l||tree[k].l>r){return 0x7f7f7f7f;}
	if(l<=tree[k].l&&r>=tree[k].r){
		return tree[k].mini;
	}
	int mid=(tree[k].l+tree[k].r)>>1;
	int ans=0x7f7f7f7f;
	if(mid>=l){
		ans=min(query(k<<1,l,r),ans);
	}
	if(mid<r){
		ans=min(query(k<<1|1,l,r),ans);
	}
	return ans;
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	maxr[n+1]=a[0]=a[n+1]=0;
	for(int i=1;i<=n;++i){
		maxl[i]=max(maxl[i-1],a[i]);
	}
	for(int i=n;i>=1;i--){
		maxr[i]=max(maxr[i+1],a[i]);
		maxr2[n+1-i]=maxr[i];
	}
	// for(int i=1;i<=n;++i){
	// 	cout<<maxr[i]<<" ";
	// }
	// cout<<"\n";
	build(1,1,n);
	for(int i=1;i<=(n/2)+1;i++){
		int pos=lower_bound(maxr2+1,maxr2+1+n,maxl[i])-maxr2;
		pos=n+1-pos;
		if(!pos||pos<=i+1){continue;}
		while(maxr[pos]==maxl[i]&&pos>i+1){
			// if(pos>=n){pos--;continue;}
			// int temp=query(1,i+1,pos-1);
			// cout<<"%"<<temp<<"\n";
			if(query(1,i+1,pos-1)==maxl[i]){
				cout<<"YES\n";
				cout<<i<<" "<<pos-i-1<<" "<<n-i-(pos-i-1)<<"\n";
				return ;
			}
			pos--;
		}
	}
	cout<<"NO\n";

}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int Case;
	cin>>Case;
	while(Case--){
		solve();
	}
}


    #include<bits/stdc++.h>
    #define LL __int128
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    const int mod=7+1e9;
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
    ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
    ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
    ll getInv(ll x,ll p){return qpow(x,p-2,p);}
    const int N=5+2e5;
    int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
    int init(int l,int r,const vector<int> &a){
        int x=++tot;
        if(l==r){ mi[x]=mx[x]=a[l]; return x; }
        int mid=l+r>>1;
        lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
        mx[x]=max(mx[lc[x]],mx[rc[x]]);
        mi[x]=min(mi[lc[x]],mi[rc[x]]);
        return x;
    }
    int que_mx(int x,int l,int r,int L,int R){
        if(l>R||r<L) return 0;
        if(L<=l&&r<=R) return mx[x];
        int mid=l+r>>1;
        return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
    }
    int que_mi(int x,int l,int r,int L,int R){
        if(l>R||r<L) return INT_MAX;
        if(L<=l&&r<=R) return mi[x];
        int mid=l+r>>1;
        return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
    }
    void solve(){
        int n; cin>>n;
        vector<int> a(n+1);
        for(int i=1;i<=n;i++) cin>>a[i];
        rt=init(1,n,a);
        for(int i=1;i<=n;i++){
            int l=i+1,r=n;
            int L=que_mx(rt,1,n,1,i);
            while(l<=r){
                int mid=l+r>>1;
                int M=que_mi(rt,1,n,i+1,mid);
                if(L<=M){
                    if(L==M&&M==que_mx(rt,1,n,mid+1,n)){
                        puts("Yes");
                        cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                        return;
                    }
                    l=mid+1;
                }else r=mid-1;
            }
        }
        puts("No");
    }
    int main(){
        int T; cin>>T;
        while(T--) solve();
    }


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a) if(b&1) ret=ret*a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int a[N];
int mi[N][100],mx[N][100];
int queMX(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return max(mx[l][k-1],mx[r+1-(1<<(k-1))][k-1]);
}
int queMI(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return min(mi[l][k-1],mi[r+1-(1<<(k-1))][k-1]);
}
void solve(){
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) mi[i][0]=mx[i][0]=a[i];
    for(int j=1,w=2;w<=n;w<<=1,j++){
        for(int i=1;i<=n;i++){
            mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
            mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
        }
    }
    for(int i=1;i<=n;i++){
        int l=i+1,r=n-1;
        int L=queMX(1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=queMI(i+1,mid);
            if(L==M){
                int R=queMX(mid+1,n);
                if(L==M&&M==R){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }else if(M>R) r=mid-1;
                else l=mid+1;
            }else if(L<M) l=mid+1;
            else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
int init(int l,int r,const vector<int> &a){
    int x=++tot;
    if(l==r){ mi[x]=mx[x]=a[l]; return x; }
    int mid=l+r>>1;
    lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
    mx[x]=max(mx[lc[x]],mx[rc[x]]);
    mi[x]=min(mi[lc[x]],mi[rc[x]]);
    return x;
}
int que_mx(int x,int l,int r,int L,int R){
    if(l>R||r<L) return 0;
    if(L<=l&&r<=R) return mx[x];
    int mid=l+r>>1;
    return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
}
int que_mi(int x,int l,int r,int L,int R){
    if(l>R||r<L) return INT_MAX;
    if(L<=l&&r<=R) return mi[x];
    int mid=l+r>>1;
    return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
}
void ord(int x,int l,int r){
    if(l==r) printf("(%d,%d)[%d,%d]\n",l,r,mi[x],mx[x]);
    else{
        int mid=l+r>>1;
        ord(lc[x],l,mid);
        printf("(%d,%d)[%d,%d]\n",l,r,mi[x],mx[x]);
        ord(rc[x],mid+1,r);
    }
}
void solve(){
    int n; cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    rt=init(1,n,a);
    //ord(rt,1,n);
    for(int i=1;i<=n;i++){
        int l=i+1,r=n;
        int L=que_mx(rt,1,n,1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=que_mi(rt,1,n,i+1,mid);
            //printf("(%d,%d)[%d,%d,%d]\n",i,mid,L,M,que_mx(rt,1,n,mid+1,n));
            if(L==M){
                int R=que_mx(rt,1,n,mid+1,n);
                if(M==R){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }else if(M>R) r=mid-1;
                else l=mid+1;
            }else if(L<M) l=mid+1;
            else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a) if(b&1) ret=ret*a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int a[N];
int mi[N][30],mx[N][30];
int queMX(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return max(mx[l][k-1],mx[r+1-(1<<(k-1))][k-1]);
}
int queMI(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return min(mi[l][k-1],mi[r+1-(1<<(k-1))][k-1]);
}
void solve(){
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) mi[i][0]=mx[i][0]=a[i];
    for(int j=1,w=2;w<=n;w<<=1,j++){
        for(int i=1;i<=n;i++){
            mx[i][j]=max(mx[i][j-1],mx[min(n,i+(1<<(j-1)))][j-1]);
            mi[i][j]=min(mi[i][j-1],mi[min(n,i+(1<<(j-1)))][j-1]);
        }
    }
    for(int i=1;i<=n;i++){
        int l=i+1,r=n-1;
        int L=queMX(1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=queMI(i+1,mid);
            if(L==M){
                int R=queMX(mid+1,n);
                if(L==M&&M==R){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }else if(M>R) r=mid-1;
                else l=mid+1;
            }else if(L<M) l=mid+1;
            else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
int init(int l,int r,const vector<int> &a){
    int x=++tot;
    if(l==r){ mi[x]=mx[x]=a[l]; return x; }
    int mid=l+r>>1;
    lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
    mx[x]=max(mx[lc[x]],mx[rc[x]]);
    mi[x]=min(mi[lc[x]],mi[rc[x]]);
    return x;
}
int que_mx(int x,int l,int r,int L,int R){
    if(l>R||r<L) return 0;
    if(L<=l&&r<=R) return mx[x];
    int mid=l+r>>1;
    return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
}
int que_mi(int x,int l,int r,int L,int R){
    if(l>R||r<L) return INT_MAX;
    if(L<=l&&r<=R) return mi[x];
    int mid=l+r>>1;
    return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
}
void ord(int x,int l,int r){
    if(l==r) printf("(%d,%d)[%d,%d]\n",l,r,mi[x],mx[x]);
    else{
        int mid=l+r>>1;
        ord(lc[x],l,mid);
        printf("(%d,%d)[%d,%d]\n",l,r,mi[x],mx[x]);
        ord(rc[x],mid+1,r);
    }
}
void solve(){
    int n; cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    rt=init(1,n,a);
    //ord(rt,1,n);
    for(int i=1;i<=n;i++){
        int l=i+1,r=n;
        int L=que_mx(rt,1,n,1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=que_mi(rt,1,n,i+1,mid);
            //printf("(%d,%d)[%d,%d,%d]\n",i,mid,L,M,que_mx(rt,1,n,mid+1,n));
            if(L==M){
                int R=que_mx(rt,1,n,mid+1,n);
                if(M==R){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }else if(M>R) r=mid-1;
                else r=mid-1;
            }else if(L<M) l=mid+1;
            else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


    #include<bits/stdc++.h>
    #define LL __int128
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    const int mod=7+1e9;
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
    ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
    ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
    ll getInv(ll x,ll p){return qpow(x,p-2,p);}
    const int N=5+2e5;
    int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
    int init(int l,int r,const vector<int> &a){
        int x=++tot;
        if(l==r){ mi[x]=mx[x]=a[l]; return x; }
        int mid=l+r>>1;
        lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
        mx[x]=max(mx[lc[x]],mx[rc[x]]);
        mi[x]=min(mi[lc[x]],mi[rc[x]]);
        return x;
    }
    int que_mx(int x,int l,int r,int L,int R){
        if(l>R||r<L) return 0;
        if(L<=l&&r<=R) return mx[x];
        int mid=l+r>>1;
        return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
    }
    int que_mi(int x,int l,int r,int L,int R){
        if(l>R||r<L) return INT_MAX;
        if(L<=l&&r<=R) return mi[x];
        int mid=l+r>>1;
        return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
    }
    void solve(){
        int n; cin>>n;
        vector<int> a(n+1);
        for(int i=1;i<=n;i++) cin>>a[i];
        tot=0;
        rt=init(1,n,a);
        for(int i=1;i<=n;i++){
            int l=i+1,r=n;
            int L=que_mx(rt,1,n,1,i);
            while(l<=r){
                int mid=l+r>>1;
                int M=que_mi(rt,1,n,i+1,mid);
                if(L<=M){
                    if(L==M&&M==que_mx(rt,1,n,mid+1,n)){
                        puts("Yes");
                        cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                        return;
                    }
                    l=mid+1;
                }else r=mid-1;
            }
        }
        puts("No");
    }
    int main(){
        int T; cin>>T;
        while(T--) solve();
    }


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
int init(int l,int r,const vector<int> &a){
    int x=++tot;
    if(l==r){ mi[x]=mx[x]=a[l]; return x; }
    int mid=l+r>>1;
    lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
    mx[x]=max(mx[lc[x]],mx[rc[x]]);
    mi[x]=min(mi[lc[x]],mi[rc[x]]);
    return x;
}
int que_mx(int x,int l,int r,int L,int R){
    if(l>R||r<L) return 0;
    if(L<=l&&r<=R) return mx[x];
    int mid=l+r>>1;
    return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
}
int que_mi(int x,int l,int r,int L,int R){
    if(l>R||r<L) return INT_MAX;
    if(L<=l&&r<=R) return mi[x];
    int mid=l+r>>1;
    return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
}
void solve(){
    int n; cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    rt=init(1,n,a);
    for(int i=1;i<=n;i++){
        int l=i+1,r=n-1;
        int L=que_mx(rt,1,n,1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=que_mi(rt,1,n,i+1,mid);
            if(L<=M){
                if(L==M&&M==que_mx(rt,1,n,mid+1,n)){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }
                l=mid+1;
            }else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


    #include<bits/stdc++.h>
    #define LL __int128
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    const int mod=7+1e9;
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
    ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
    ll qpow(ll a,ll b){ll ret=1; for(;b;b>>=1,a*=a) if(b&1) ret*=a; return ret;}
    ll getInv(ll x,ll p){return qpow(x,p-2,p);}
    const int N=5+1e6;
    int rt,tot,lc[N<<2],rc[N<<2],mi[N<<2],mx[N<<2];
    int init(int l,int r,const vector<int> &a){
        int x=++tot;
        if(l==r){ mi[x]=mx[x]=a[l]; return x; }
        int mid=l+r>>1;
        lc[x]=init(l,mid,a),rc[x]=init(mid+1,r,a);
        mx[x]=max(mx[lc[x]],mx[rc[x]]);
        mi[x]=min(mi[lc[x]],mi[rc[x]]);
        return x;
    }
    int que_mx(int x,int l,int r,int L,int R){
        if(l>R||r<L) return 0;
        if(L<=l&&r<=R) return mx[x];
        int mid=l+r>>1;
        return max(que_mx(lc[x],l,mid,L,R),que_mx(rc[x],mid+1,r,L,R));
    }
    int que_mi(int x,int l,int r,int L,int R){
        if(l>R||r<L) return INT_MAX;
        if(L<=l&&r<=R) return mi[x];
        int mid=l+r>>1;
        return min(que_mi(lc[x],l,mid,L,R),que_mi(rc[x],mid+1,r,L,R));
    }
    void solve(){
        int n; cin>>n;
        vector<int> a(n+1);
        for(int i=1;i<=n;i++) cin>>a[i];
        rt=init(1,n,a);
        for(int i=1;i<=n;i++){
            int l=i+1,r=n;
            int L=que_mx(rt,1,n,1,i);
            while(l<=r){
                int mid=l+r>>1;
                int M=que_mi(rt,1,n,i+1,mid);
                if(L<=M){
                    if(L==M&&M==que_mx(rt,1,n,mid+1,n)){
                        puts("Yes");
                        cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                        return;
                    }
                    l=mid+1;
                }else r=mid-1;
            }
        }
        puts("No");
    }
    int main(){
        int T; cin>>T;
        while(T--) solve();
    }


#include<bits/stdc++.h>
#define LL __int128
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a) if(b&1) ret=ret*a; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
int a[N];
int mi[N][30],mx[N][30];
int queMX(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return max(mx[l][k-1],mx[r+1-(1<<(k-1))][k-1]);
}
int queMI(int l,int r){
    int k=0; for(int x=r-l+1;x;x>>=1) k++;
    return min(mi[l][k-1],mi[r+1-(1<<(k-1))][k-1]);
}
void solve(){
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) mi[i][0]=mx[i][0]=a[i];
    for(int j=1,w=2;w<=n;w<<=1,j++){
        for(int i=1;i<=n;i++){
            mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
            mi[i][j]=min(mi[i][j-1],mi[i+(1<<(j-1))][j-1]);
        }
    }
    for(int i=1;i<=n;i++){
        int l=i+1,r=n-1;
        int L=queMX(1,i);
        while(l<=r){
            int mid=l+r>>1;
            int M=queMI(i+1,mid);
            if(L==M){
                int R=queMX(mid+1,n);
                if(L==M&&M==R){
                    puts("Yes");
                    cout<<i<<' '<<mid-i<<' '<<n-mid<<endl;
                    return;
                }else if(M>R) r=mid-1;
                else l=mid+1;
            }else if(L<M) l=mid+1;
            else r=mid-1;
        }
    }
    puts("No");
}
int main(){
    int T; cin>>T;
    while(T--) solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+54;
const ll INF=1e18;
const ll M=2222;
const ll mod=1e9+7;
ll a[N],n,m,x,y,z,d,vis[N],ans,in[N],cnt;
struct node
{
    ll l,r,Max,Min;
}t[N<<2];
string s,ss;
vector<ll>ve[N];
map<ll,ll>mp;
set<ll>se;
void buile(ll p,ll l,ll r)
{
    t[p].l=l,t[p].r=r;
    if(l==r)
    {
        cin>>t[p].Max;
        t[p].Min=t[p].Max;
    }
    else
    {
        ll mid=(l+r)>>1;
        buile(p<<1,l,mid);
        buile(p<<1|1,mid+1,r);
        t[p].Max=max(t[p<<1].Max,t[p<<1|1].Max);
        t[p].Min=min(t[p<<1].Min,t[p<<1|1].Min);
    }

}
ll query_min(ll p,ll l,ll r)
{
	if(t[p].l>r || t[p].r<l)return INF;
	if(t[p].l>=l && t[p].r<=r)return t[p].Min;
	return min(query_min(p<<1,l,r),query_min(p<<1|1,l,r));
}

ll query_max(ll p,ll l,ll r)
{
	if(t[p].l>r || t[p].r<l)return -INF;
	if(t[p].l>=l && t[p].r<=r)return t[p].Max;
	return max(query_max(p<<1,l,r),query_max(p<<1|1,l,r));
}
void solve()
{
    ll cnt=0,c0=0,c1=0,h,mx=INF,ans1=0,q,ff=0;
    ans=0;
    cin>>n;
    //for(int i=1;i<=n;i++)cin>>a[i];
    buile(1,1,n);
    for(int x=1;x<n-1;x++)
    {
        ll l=x+1,r=n-1;
        ll max1=query_max(1,1,x);
        while(l<=r)
        {
            ll y=l+r>>1;
            ll minn=query_min(1,x+1,y);
            ll max2=query_max(1,y+1,n);
            if(max1<minn || max1<max2)l=y+1;
            else if(max1>minn || max1>max2)r=y-1;
            else
            {
                cout<<"YES"<<endl;
                printf("%d %lld %lld\n",x,y-x,n-y);
                ff=1;
                break;
            }
        }
        if(ff)break;
    }
    if(!ff)cout<<"NO"<<endl;
}
int main()
{
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ios::sync_with_stdio(0);
    ll T;cin>>T;
    while(T--)
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+54;
const ll INF=1e18;
const ll M=2222;
const ll mod=1e9+7;
ll a[N],n,m,x,y,z,d,vis[N],ans,in[N],cnt;
struct node
{
    ll l,r,Max,Min;
}t[N<<2];
string s,ss;
vector<ll>ve[N];
map<ll,ll>mp;
set<ll>se;
void buile(ll p,ll l,ll r)
{
    t[p].l=l,t[p].r=r;
    if(l==r)
    {
        scanf("%lld",&t[p].Max);
        t[p].Min=t[p].Max;
    }
    else
    {
        ll mid=(l+r)>>1;
        buile(p<<1,l,mid);
        buile(p<<1|1,mid+1,r);
        t[p].Max=max(t[p<<1].Max,t[p<<1|1].Max);
        t[p].Min=min(t[p<<1].Min,t[p<<1|1].Min);
    }

}
ll query_min(ll p,ll l,ll r)
{
	if(t[p].l>r || t[p].r<l)return INF;
	if(t[p].l>=l && t[p].r<=r)return t[p].Min;
	return min(query_min(p<<1,l,r),query_min(p<<1|1,l,r));
}

ll query_max(ll p,ll l,ll r)
{
	if(t[p].l>r || t[p].r<l)return -INF;
	if(t[p].l>=l && t[p].r<=r)return t[p].Max;
	return max(query_max(p<<1,l,r),query_max(p<<1|1,l,r));
}
void solve()
{
    ll cnt=0,c0=0,c1=0,h,mx=INF,ans1=0,q,ff=0;
    ans=0;
    scanf("%lld",&n);
    //for(int i=1;i<=n;i++)cin>>a[i];
    buile(1,1,n);
    for(int x=1;x<n-1;x++)
    {
        ll l=x+1,r=n-1;
        ll max1=query_max(1,1,x);
        while(l<=r)
        {
            ll y=l+r>>1;
            ll minn=query_min(1,x+1,y);
            ll max2=query_max(1,y+1,n);
            if(max1<minn || max1<max2)l=y+1;
            else if(max1>minn || max1>max2)r=y-1;
            else
            {
                cout<<"YES"<<endl;
                printf("%d %lld %lld\n",x,y-x,n-y);
                ff=1;
                break;
            }
        }
        if(ff)break;
    }
    if(!ff)cout<<"NO"<<endl;
}
int main()
{
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    //ios::sync_with_stdio(0);
    ll T;cin>>T;
    while(T--)
    solve();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<cassert>
#include<bitset>
using namespace std;

typedef long long LL;

typedef unsigned long long ull;

const int inf=0x3f3f3f3f;

const int N=1e6+100;

struct Node
{
	int l,r,mmin,mmax;
}tree[N<<2];

void build(int k,int l,int r)
{
	tree[k].l=l;
	tree[k].r=r;
	if(l==r)
	{
		scanf("%d",&tree[k].mmax);
		tree[k].mmin=tree[k].mmax;
		return;
	}
	int mid=l+r>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	tree[k].mmax=max(tree[k<<1].mmax,tree[k<<1|1].mmax);
	tree[k].mmin=min(tree[k<<1].mmin,tree[k<<1|1].mmin);
}

int query_min(int k,int l,int r)
{
	if(tree[k].l>r||tree[k].r<l)
		return inf;
	if(tree[k].l>=l&&tree[k].r<=r)
		return tree[k].mmin;
	return min(query_min(k<<1,l,r),query_min(k<<1|1,l,r));
}

int query_max(int k,int l,int r)
{
	if(tree[k].l>r||tree[k].r<l)
		return -inf;
	if(tree[k].l>=l&&tree[k].r<=r)
		return tree[k].mmax;
	return max(query_max(k<<1,l,r),query_max(k<<1|1,l,r));
}

int main()
{
	int w;
	cin>>w;
	while(w--)
	{
		int n,f=0;
		scanf("%d",&n);
		build(1,1,n);
		for(int x=1;x<n-1;x++)
		{
			int l=x+1,r=n-1;
			int mmax1=query_max(1,1,x);
			while(l<=r)
			{
				int y=l+r>>1;
				int mmin=query_min(1,x+1,y);
				int mmax2=query_max(1,y+1,n);
				if(mmax1<mmin||mmax1<mmax2)
					l=y+1;
				else if(mmax1>mmin||mmax1>mmax2)
					r=y-1;
				else
				{
					puts("YES");
					printf("%d %d %d\n",x,y-x,n-y);
					f=1;
					break;
				}
			}
			if(f)break;
		}
		if(!f)puts("NO");

	}
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 1;
int n, q, events[N];
bool vis[N];
vector<vector<int> > all;

int main() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
#endif

  scanf("%d %d", &n, &q);
  all.resize(n + 1);
  int type, x, sum = 0, lst = 1, tmp = 0, evecnt = 1;
  for(int i = 1; i <= q; ++i) {
    scanf("%d %d", &type, &x);

    if(type == 1) {
      all[x].push_back(i);
      events[evecnt++] = x;
      sum += 1;
    } else if(type == 2) {
      tmp = 0;
      for(int j = 0; j < all[x].size(); ++j) {
        if(vis[all[x][j]])
          continue;
        vis[all[x][j]] = true;
        ++tmp;
      }
      all[x].clear();
      sum -= tmp;
    } else {
      for(int j = lst; j <= x; ++j) {
        if(vis[j])
          continue;
        --sum;
        vis[j] = true;
      }
      lst = x + 1;
    }

    printf("%d\n", sum);
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 1;
int n, q, cnt[N], events[N];
bool vis[N];
vector<vector<int> > all;

int main() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
#endif

  scanf("%d %d", &n, &q);
  all.resize(n + 1);
  int type, x, sum = 0, lst = 0, tmp = 0;
  for(int i = 0; i < q; ++i) {
    scanf("%d %d", &type, &x);

    if(type == 1) {
      ++cnt[x];
      all[x].push_back(i);
      events[i] = x;
      sum += 1;
    } else if(type == 2) {
      tmp = 0;
      for(int j = 0; j < all[x].size(); ++j) {
        if(vis[all[x][j]])
          continue;
        vis[all[x][j]] = true;
        ++tmp;
      }
      all[x].clear();
      cnt[x] = 0;
      sum -= tmp;
    } else {
      for(int j = lst; j < x; ++j) {
        if(vis[j] || events[j] == 0)
          continue;
        vis[j] = true;
        --cnt[events[j]];
        --sum;
      }
      lst = x + 1;
    }

    printf("%d\n", sum);
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 1;
int n, q, cnt[N], events[N], to[N];
bool vis[N];
vector<vector<int> > all;

int main() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
#endif

  scanf("%d %d", &n, &q);
  all.resize(n + 1);
  int type, x, sum = 0, lst = 1, tmp = 0, evecnt = 1;
  for(int i = 1; i <= q; ++i) {
    scanf("%d %d", &type, &x);

    if(type == 1) {
      ++cnt[x];
      events[evecnt++] = x;
      ++sum;
    } else if(type == 2) {
      sum -= cnt[x];
      to[x] = evecnt;
    } else {
      for(int j = lst; j <= x; ++j) {
        if(vis[j])
          continue;
        if(to[events[x]] >= j) {
          vis[j] = true;
          continue;
        }
        --sum;
        --cnt[events[j]];
        vis[j] = true;
      }
      lst = x + 1;
    }

    printf("%d\n", sum);
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 1;
int n, q, cnt[N], events[N], to[N], res[N];
bool vis[N];

int main() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
#endif

  scanf("%d %d", &n, &q);
  int type, x, sum = 0, lst = 1, tmp = 0, evecnt = 1;
  for(int i = 1; i <= q; ++i) {
    scanf("%d %d", &type, &x);

    if(type == 1) {
      ++sum;
      ++cnt[x];
      events[evecnt++] = x;
    } else if(type == 2) {
      sum -= cnt[x];
      cnt[x] = 0;
      to[x] = evecnt - 1;
    } else {
      for(int j = lst; j <= x; ++j) {
        if(vis[j])
          continue;
        if(to[events[j]] >= j) {
          vis[j] = true;
          continue;
        }
        --sum;
        --cnt[events[j]];
        vis[j] = true;
      }
      lst = x + 1;
    }

    res[i] = sum;
  }

  for(int i = 1; i <= q; ++i)
    printf("%d\n", res[i]);

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int const N = 3e5 + 1;
int n, q, events[N];
bool vis[N];
vector<vector<int> > all;

int main() {
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
#endif

  scanf("%d %d", &n, &q);
  all.resize(n + 1);
  int type, x, sum = 0, lst = 1, tmp = 0;
  for(int i = 1; i <= q; ++i) {
    scanf("%d %d", &type, &x);

    if(type == 1) {
      all[x].push_back(i);
      events[i] = x;
      sum += 1;
    } else if(type == 2) {
      tmp = 0;
      for(int j = 0; j < all[x].size(); ++j) {
        if(vis[all[x][j]])
          continue;
        vis[all[x][j]] = true;
        ++tmp;
      }
      all[x].clear();
      sum -= tmp;
    } else {
      for(int j = lst, rem = lst; rem <= x; ++j) {
        if(vis[j] || events[j] == 0) {
          rem += events[j] != 0;
          continue;
        }
        ++rem;
        vis[j] = true;
        --sum;
      }
      lst = x + 1;
    }

    printf("%d\n", sum);
  }

  return 0;
}


/*
    let s be set stores the unread messages
    and adj[x] be the messages of application x
    simply when query of type 2 is happened , iterate over unread messages x and delete them from s
    and query of type 3 , iterate over all messages it's index less than t and delete them from adj[k] s.t. k the application of the message
*/

#include <bits/stdc++.h>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long  ll;

const int N = 3e5 + 4;
int n , q;
set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n >> q;

    int cnt = 0 , message = 1;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({message , t});
            adj[t].insert(message);
            message++;
            cnt++;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else if(!s.empty()){
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0 , message = 1;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({message++ , t});
            adj[t].insert(i);
            ++cnt;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else{
            if(s.empty())continue;
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({i , t});
            adj[t].insert(i);
            ++cnt;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else{
            if(s.empty())continue;
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0 , message = 1;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({message , t});
            adj[t].insert(message);
            message++;
            ++cnt;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else{
            if(s.empty())continue;
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0 , message = 1;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({message , t});
            adj[t].insert(message);
            message++;
            cnt++;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else if(!s.empty()){
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0 , message = 1;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({message , t});
            adj[t].insert(message);
            message++;
            cnt++;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else if(!s.empty()){
            auto it = s.begin();
            while((*it).first <= t){
                int x = (*it).second , ind = (*it).first;
                adj[x].erase(ind);
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace __gnu_pbds;
using namespace std;
typedef long long  ll;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 4;
int n , q;
ordered_set<pair<int , int> > s;
set<int> adj[N];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
#endif
    cin >> n >> q;

    int cnt = 0;
    for(int i = 1 ; i <= q ; ++i){
        int type , t;
        cin >> type >> t;
        if(type == 1){
            s.insert({i , t});
            adj[t].insert(i);
            ++cnt;
        }
        else if(type == 2){
            for(int x : adj[t]){
                auto it = s.lower_bound({x , t});
                s.erase(it);
            }
            cnt -= adj[t].size();
            adj[t].clear();
        }
        else{
            if(s.empty())continue;
            auto it = s.begin();
            while((*it).first <= t){
                s.erase(it);
                --cnt;
                if(s.empty())break;
                it = s.begin();
            }
        }

        cout << cnt << '\n';
    }
}