#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        if(l==0 || r==n-1){
            cout << "NO\n";
            continue;
        }
        while(1){
            if((mina == pl[l-1]) && (mina == pr[r+1])){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l-1];
                ll mxr = pr[r+1];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l-1];
                mxr = pr[r+1];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>ans2){
                    l--;
                    mina = min(mina,a[l]);
                }
                else{
                    r++;
                    mina = min(mina,a[r]);
                }
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}

/*
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        while(l>0 && r<n-1){
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l];
                ll mxr = pr[r];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l];
                mxr = pr[r];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>=ans2){
                    l--;
                }
                else{
                    r++;
                }
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        while(1){
//            cout << l << " " << r << endl;
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l];
                ll mxr = pr[r];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l];
                mxr = pr[r];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>ans2){
                    l--;
                    mina = min(mina,a[l]);
                }
                else{
                    r++;
                    mina = min(mina,a[r]);
                }
            }
        }
        if(l>0 && r<n-1){
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}

/*
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        if(l==0 || r==n-1){
            cout << "NO\n";
            continue;
        }
        while(1){
            if((mina == pl[l-1]) && (mina == pr[r+1])){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l];
                ll mxr = pr[r];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l];
                mxr = pr[r];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>ans2){
                    l--;
                    mina = min(mina,a[l]);
                }
                else{
                    r++;
                    mina = min(mina,a[r]);
                }
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}

/*
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        while(l>0 && r<n-1){
//            cout << l << " " << r << endl;
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l];
                ll mxr = pr[r];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l];
                mxr = pr[r];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>=ans2){
                    l--;
                    mina = min(mina,a[l]);
                }
                else{
                    r++;
                    mina = min(mina,a[r]);
                }
            }
        }
        if(l>0 && r<n-1){
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}

/*
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define SIZE 100000
#define MAX 200005
#define MOD 1000000007
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

	fast

	Q{
        ll n;
        cin >> n;
        ll a[n];
        for(ll i=0;i<n;i++){
            cin >> a[i];
        }
        ll pl[n],pr[n];
        pl[0] = a[0];
        pr[n-1] = a[n-1];
        for(ll i=1;i<n;i++){
            pl[i] = max(a[i],pl[i-1]);
        }
        for(ll i=n-2;i>=0;i--){
            pr[i] = max(a[i],pr[i+1]);
        }

        ll maxa = 0;
        for(ll i=0;i<n;i++){
            maxa = max(maxa,a[i]);
        }
        ll cnt = 0;
        for(ll i=0;i<n;i++){
            if(a[i]==maxa){
                cnt++;
            }
        }

        ll l = -1;
        ll r = -1;
        if(cnt>=3){
            int flg = 0;
            ll ans = -1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg){
                        ans = i;
                        break;
                    }
                    flg = 1;
                }
            }
            cout << "YES\n";
            cout << ans << " 1 " << n-ans-1 << endl;
            continue;
        }
        else if(cnt==2){
            int flg = 1;
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    if(flg==1){
                        l = i;
                        flg = 2;
                    }
                    else{
                        r = i;
                    }
                }
            }
        }
        else{
            for(ll i=0;i<n;i++){
                if(a[i]==maxa){
                    l = i;
                    r = i;
                }
            }
        }
        ll mina = a[l];
        for(ll i=l;i<=r;i++){
            mina = min(mina,a[i]);
        }

        ll ansl = -1;
        ll ansr = -1;
        while(l>0 && r<n-1){
//            cout << l << " " << r << endl;
            if(mina == pl[l-1] && mina == pr[r+1]){
                ansl = l;
                ansr = r;
                break;
            }
            else if(l==1 && r==n-2){
                break;
            }
            else if(l==1){
                r++;
                mina = min(mina,a[r]);
            }
            else if(r==n-2){
                l--;
                mina = min(mina,a[l]);
            }
            else{
                l--;
                ll minat = min(mina,a[l]);
                ll mxl = pl[l];
                ll mxr = pr[r];
                ll ans1 = min(minat,mxl);
                ans1 = min(ans1,mxr);
                l++;
                r++;
                minat = min(mina,a[r]);
                mxl = pl[l];
                mxr = pr[r];
                ll ans2 = min(minat,mxl);
                ans2 = min(ans2,mxr);
                r--;
                if(ans1>=ans2){
                    l--;
                    mina = min(mina,a[l]);
                }
                else{
                    r++;
                    mina = min(mina,a[r]);
                }
            }
        }
        if(ansl==-1){
            cout << "NO\n";
        }
        else{
            cout << "YES\n";
            cout << l << " " << r-l+1 << " " << n - l - (r-l+1) << endl;
        }
	}

}

/*
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }

    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n-i)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        if(i+pos>=n)continue;
        if(mb[pos]!=mp[i])continue;
        if(query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }
    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n-i)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        //if(i+pos>=n)continue;
        if(mb[pos]==mp[i]&&query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }

    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n-i)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        //if(i+pos>=n)continue;
        if(mb[pos]==mp[i]&&query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
        if(mp[i]==mb[n-i-1]&&query(1,1,n,i+1,i+1)==mp[i]){
            int x=i,y=1,z=n-x-y;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e6+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }

    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        if(i+pos>=n)continue;
        if(mb[pos]!=mp[i])continue;
        if(query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos-1,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }
    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
set<pii>st;
void solve(){
    for(int i=1;i<=n-2;i++){
        st.erase(pii(arr[i],i));
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n-i)pos=n-i-1;

        //cout<<i<<" "<<pos<<endl;
        //if(i+pos>=n)continue;
        if(mb[pos]==mp[i]&&query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
        auto ite=st.lower_bound(pii(mp[i],0));
        if(ite==st.end())continue;
        pii _=*ite;
        pos=n-_.second;
        //cout<<pos<<endl;
        if(mb[pos]==mp[i]&&query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }

    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        st.clear();
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            st.insert(pii(arr[i],i));
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }

    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n-i)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        //if(i+pos>=n)continue;
        if(mb[pos]!=mp[i])continue;
        if(query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e6+20;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
int tree[MAXN*4];

void update(int nod,int l,int r,int k,int v){
    if(l==r){
        tree[nod]=v;
        return;
    }
    int mid=(l+r)/2;
    if(k<=mid){
        update(nod*2,l,mid,k,v);
    }
    else{
        update(nod*2+1,mid+1,r,k,v);
    }

    tree[nod]=min(tree[nod*2],tree[nod*2+1]);
}
int query(int nod,int l,int r,int ll,int rr){
    if(l==ll&&r==rr){
        return tree[nod];
    }
    int mid=(l+r)/2;
    if(mid>=rr){
        return query(nod*2,l,mid,ll,rr);
    }
    else if(mid<ll){
        return query(nod*2+1,mid+1,r,ll,rr);
    }
    else return min(query(nod*2,l,mid,ll,mid),query(nod*2+1,mid+1,r,mid+1,rr));
}

int arr[MAXN];
int mp[MAXN],mb[MAXN];
int n;
void solve(){
    for(int i=1;i<=n-2;i++){
        int pos=upper_bound(mb+1,mb+n+1,mp[i])-mb;
        pos=pos-1;
        if(pos>=n)pos=n-i-1;
        //cout<<i<<" "<<pos<<endl;
        if(i+pos>=n)continue;
        if(mb[pos]!=mp[i])continue;
        if(query(1,1,n,i+1,n-pos)==mp[i]){
            int x=i,z=pos,y=n-x-z;
            printf("YES\n");
            printf("%d %d %d\n",x,y,z);
            return;
        }
    }
    printf("NO\n");
}
int main(){
    //freopen("1.in","r",stdin);
    int test;
    scanf("%d",&test);
    while(test--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&arr[i]);
            update(1,1,n,i,arr[i]);
        }
        mp[0]=mb[n+1]=0;
        for(int i=1;i<=n;i++)mp[i]=max(mp[i-1],arr[i]);
        for(int i=n;i>=1;i--)mb[i]=max(mb[i+1],arr[i]);
        reverse(mb+1,mb+1+n);
        solve();

    }
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e5+5;
int n;
int a[N];
int pre[N];
int suf[N];
int f[N][20];
unordered_map<int,int> mp;
void ST_prework() {
    for(int i = 1; i <= n; ++i)
        f[i][0] = a[i];
    int t = log(n) / log(2) + 1;
    for(int j = 1; j < t; ++j) {
        for(int i = 1; i <= n - (1 << j) + 1; ++i) {
            f[i][j] = min(f[i][j-1], f[i + (1 << (j-1))][j - 1]);
        }
    }
}
int ST_query(int l, int r) {
    int k;
    if(mp[r-l+1])
        k = mp[r-l+1];
    else
        k = mp[r-l+1] = log(r - l + 1) / log(2);
    return min(f[l][k], f[r - (1 << k) + 1][k]);
}

int main() {
    int t;
    cin >> t;
    while(t--){
//        memset(f,0,sizeof f);
//        memset(a,0,sizeof a);
//        memset(pre,0,sizeof pre);
//        memset(suf,0,sizeof suf);
//        mp.clear();
        cin >> n;
        for(int i = 1; i <= n; ++i){
            cin >> a[i];
            pre[0] = suf[0] = 0;
        }
        pre[0] = suf[n+1] = 0;
        for(int i = 1; i <= n; ++i)
            pre[i] = max(pre[i-1],a[i]);
        for(int i = n; i >= 1; --i)
            suf[i] = max(suf[i+1],a[i]);
        ST_prework();
        int l = 1;
        int r = n;
        int flag = 0;
        while(l < r - 1){
            if(pre[l] == suf[r] && ST_query(l+1,r-1) == pre[l]){
//                cout << "l: " << l+1 << " r: " << r-1 << " ans: " << ST_query(l+1,r-1) << "\n";
                flag = 1;
                break;
            }
            if(pre[l] > suf[r])
                --r;
            else if(pre[l] < suf[r])
                ++l;
            else if(a[l+1] < pre[l] || a[r-1] > suf[r])
                ++l;
            else if(a[r-1] < suf[r] || a[l+1] > pre[l])
                --r;
            else
                ++l,--r;
        }
        int x = l;
        int y = r - l - 1;
        int z = n - x - y;
        if(flag){
            cout << "YES\n";
            cout << x << " " << y << " " << z << "\n";
        }else {
            cout << "NO\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e5+5;
int n;
int a[N];
int pre[N];
int suf[N];
int f[N][20];
unordered_map<int,int> mp;
void ST_prework() {
    for(int i = 1; i <= n; ++i)
        f[i][0] = a[i];
    int t = log(n) / log(2) + 1;
    for(int j = 1; j < t; ++j) {
        for(int i = 1; i <= n - (1 << j) + 1; ++i) {
            f[i][j] = min(f[i][j-1], f[i + (1 << (j-1))][j - 1]);
        }
    }
}
int ST_query(int l, int r) {
    int k;
    if(mp[r-l+1])
        k = mp[r-l+1];
    else
        k = mp[r-l+1] = log(r - l + 1) / log(2);
    return min(f[l][k], f[r - (1 << k) + 1][k]);
}

int main() {
    int t;
    cin >> t;
    while(t--){
//        memset(f,0,sizeof f);
//        memset(a,0,sizeof a);
//        memset(pre,0,sizeof pre);
//        memset(suf,0,sizeof suf);
//        mp.clear();
        cin >> n;
        for(int i = 1; i <= n; ++i){
            cin >> a[i];
            pre[0] = suf[0] = 0;
        }
        pre[0] = suf[n+1] = 0;
        for(int i = 1; i <= n; ++i)
            pre[i] = max(pre[i-1],a[i]);
        for(int i = n; i >= 1; --i)
            suf[i] = max(suf[i+1],a[i]);
        ST_prework();
        int l = 1;
        int r = n;
        int flag = 0;
        while(l < r - 1){
            if(pre[l] == suf[r] && ST_query(l+1,r-1) == pre[l]){
//                cout << "l: " << l+1 << " r: " << r-1 << " ans: " << ST_query(l+1,r-1) << "\n";
                flag = 1;
                break;
            }
            if(pre[l] > suf[r])
                --r;
            else if(pre[l] < suf[r])
                ++l;
            else if(a[l+1] < a[r-1])
                ++l;
            else
                --r;
//            else
//                ++l,--r;
        }
        int x = l;
        int y = r - l - 1;
        int z = n - x - y;
        if(flag){
            cout << "YES\n";
            cout << x << " " << y << " " << z << "\n";
        }else {
            cout << "NO\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e5+5;
int n;
int a[N];
int pre[N];
int suf[N];
int f[N][20];
unordered_map<int,int> mp;
void ST_prework() {
    for(int i = 1; i <= n; ++i)
        f[i][0] = a[i];
    int t = log(n) / log(2) + 1;
    for(int j = 1; j < t; ++j) {
        for(int i = 1; i <= n - (1 << j) + 1; ++i) {
            f[i][j] = min(f[i][j-1], f[i + (1 << (j-1))][j - 1]);
        }
    }
}
int ST_query(int l, int r) {
    int k;
    if(mp[r-l+1])
        k = mp[r-l+1];
    else
        k = mp[r-l+1] = log(r - l + 1) / log(2);
    return min(f[l][k], f[r - (1 << k) + 1][k]);
}

int main() {
    int t;
    cin >> t;
    while(t--){
//        memset(f,0,sizeof f);
//        memset(a,0,sizeof a);
//        memset(pre,0,sizeof pre);
//        memset(suf,0,sizeof suf);
//        mp.clear();
        cin >> n;
        for(int i = 1; i <= n; ++i){
            cin >> a[i];
            pre[0] = suf[0] = 0;
        }
        pre[0] = suf[n+1] = 0;
        for(int i = 1; i <= n; ++i)
            pre[i] = max(pre[i-1],a[i]);
        for(int i = n; i >= 1; --i)
            suf[i] = max(suf[i+1],a[i]);
        ST_prework();
        int l = 1;
        int r = n;
        int flag = 0;
        while(l < r - 1){
            if(pre[l] == suf[r] && ST_query(l+1,r-1) == pre[l]){
//                cout << "l: " << l+1 << " r: " << r-1 << " ans: " << ST_query(l+1,r-1) << "\n";
                flag = 1;
                break;
            }
            if(pre[l] > suf[r])
                --r;
            else if(pre[l] < suf[r])
                ++l;
            else if(a[l+1] < pre[l])
                ++l;
            else
                --r;
        }
        int x = l;
        int y = r - l - 1;
        int z = n - x - y;
        if(flag){
            cout << "YES\n";
            cout << x << " " << y << " " << z << "\n";
        }else {
            cout << "NO\n";
        }

    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e5+5;
int n;
int a[N];
int pre[N];
int suf[N];
int f[N][20];
unordered_map<int,int> mp;
void ST_prework() {
    for(int i = 1; i <= n; ++i)
        f[i][0] = a[i];
    int t = log(n) / log(2) + 1;
    for(int j = 1; j < t; ++j) {
        for(int i = 1; i <= n - (1 << j) + 1; ++i) {
            f[i][j] = min(f[i][j-1], f[i + (1 << (j-1))][j - 1]);
        }
    }
}
int ST_query(int l, int r) {
    int k;
    if(mp[r-l+1])
        k = mp[r-l+1];
    else
        k = mp[r-l+1] = log(r - l + 1) / log(2);
    return min(f[l][k], f[r - (1 << k) + 1][k]);
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        cin >> n;
        for(int i = 1; i <= n; ++i) {
            cin >> a[i];
            pre[0] = suf[0] = 0;
        }
        pre[0] = suf[n+1] = 0;
        for(int i = 1; i <= n; ++i)
            pre[i] = max(pre[i-1],a[i]);
        for(int i = n; i >= 1; --i)
            suf[i] = max(suf[i+1],a[i]);
        ST_prework();
        int flag = 0;
        int x,y,z;
//        int x = l;
//        int y = r - l - 1;
//        int z = n - x - y;
        for(int i = 1; i <= n-2; ++i) {
            int l = i + 1;
            int r = n - 1;
//            cout << "now: " << l << " " << r << "\n";
            while(l <= r) {
                int mid = (l + r) / 2;
//                cout << "!!! " << l << " " << r << "\n";
                if(pre[i] < ST_query(i+1,mid)) {
                    l = mid + 1;
                } else if(pre[i] > ST_query(i+1,mid)) {
                    r = mid - 1;
                } else {
                    if(ST_query(i+1,mid) == suf[mid+1]) {
                        flag = 1;
                        x = i;
                        y = mid+1 - i - 1;
                        z = n - x - y;
                        break;
                    } else if(ST_query(i+1,mid) > suf[mid+1]) {
                        r = mid - 1;
                    } else {
                        l = mid + 1;
                    }
                }
            }
        }
        if(flag) {
            cout << "YES\n";
            cout << x << " " << y << " " << z << "\n";
        } else {
            cout << "NO\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	while(ncase--){
		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l]) l++;
						while(lm > v[l]) l++;
						lm = v[l];
						while(v[l+1] < lm) l++;
					}
					else{
						while(rm == v[r]) r--;
						while(rm > v[r]) r--;
						rm = v[r];
						while(v[r-1] < rm) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l]) l++;
				while(lm > v[l]) l++;
				lm = v[l];
				while(v[l+1] < lm) l++;
			}
			else{
				while(rm == v[r]) r--;
				while(rm > v[r]) r--;
				rm = v[r];
				while(v[r-1] < rm) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<string.h>
#include<iostream>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define d(x) printf("%lld\n",x);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll INF= 1e17;
const ll maxn = 2e5+700;
const int mod= 1e9+7;
template<typename T>inline void read(T &a){char c=getchar();T x=0,f=1;while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+c-'0';c=getchar();}a=f*x;}
ll n,m,p;
ll num[maxn];
vector<int>v[maxn];
vector<int>g;
int premi[maxn],curmi[maxn],premx[maxn],curmx[maxn];
int st[maxn];
int nn;
int getid(ll x){
    return lower_bound(g.begin(),g.end(),x) - g.begin() + 1;
}
int main(){
    int T;scanf("%d",&T);
    while(T--){
        read(n);
        for(int i=1;i<=n;i++) v[i].clear();
        g.clear();
        for(int i=1;i<=n;i++){
            read(num[i]);
            g.push_back(num[i]);
        }
        sort(g.begin(),g.end());
        g.erase((unique(g.begin(),g.end())),g.end());
        nn = g.size();
        for(int i=1;i<=n;i++) num[i] = getid(num[i]);
        int s = 0;
        st[0] = 0;
        for(int i=1;i<=n;i++){
            while(s && num[i]>=num[st[s]]) s--;
            premx[i] = st[s]+1;
            st[++s] = i;
        }
        s = 0;
        st[0] = n+1;
        for(int i=n;i>=1;i--){
            while(s && num[i]>=num[st[s]]) s--;
            curmx[i] = st[s]-1;
            st[++s] = i;
        }

        s = 0;
        st[0] = 0;
        for(int i=1;i<=n;i++){
            while(s && num[i]<=num[st[s]]) s--;
            premi[i] = st[s]+1;
            st[++s] = i;
        }
        s = 0;
        st[0] = n+1;
        for(int i=n;i>=1;i--){
            while(s && num[i]<=num[st[s]]) s--;
            curmi[i] = st[s]-1;
            st[++s] = i;
        }

        for(int i=1;i<=n;i++) v[num[i]].push_back(i);
        int f = 0;
        for(int i=1;i<=n;i++){
            int sz = v[i].size();
            if(sz<3) continue;
            if(premx[v[i][0]]==1 && curmx[v[i][sz-1]] == n){
                for(int k=1;k<sz-1;k++){
                    int id = v[i][k];
                    if(premi[id]<=curmx[v[i][0]]+1&&curmi[id]>=premx[v[i][sz-1]]-1){
                        f = 1;
                        printf("YES\n");
                        int r = max(id+1,premx[v[i][sz-1]]);
                        ll resc = n-r+1;
                        int l = min(id-1,curmx[v[i][0]]);
                        ll resa = l;
                        printf("%lld %lld %lld\n",resa,n-resa-resc,resc);
                        break;
                    }
                }
            }
            if(f) break;
        }
        if(!f) printf("NO\n");
    }
    return 0;
}
/***
6
11
1 2 3 3 3 4 4 3 4 2 1
***/


/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<string.h>
#include<iostream>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define d(x) printf("%lld\n",x);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll INF= 1e17;
const ll maxn = 2e5+700;
const int mod= 1e9+7;
template<typename T>inline void read(T &a){char c=getchar();T x=0,f=1;while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+c-'0';c=getchar();}a=f*x;}
ll n,m,p;
ll num[maxn];
vector<int>v[maxn];
vector<int>g;
int premi[maxn],curmi[maxn],premx[maxn],curmx[maxn];
int st[maxn];
int nn;
int getid(ll x){
    return lower_bound(g.begin(),g.end(),x) - g.begin() + 1;
}
int main(){
    int T;scanf("%d",&T);
    while(T--){
        read(n);
        for(int i=1;i<=n;i++) v[i].clear();
        g.clear();
        for(int i=1;i<=n;i++){
            read(num[i]);
            g.push_back(num[i]);
        }
        sort(g.begin(),g.end());
        g.erase((unique(g.begin(),g.end())),g.end());
        nn = g.size();
        for(int i=1;i<=n;i++) num[i] = getid(num[i]);
        int s = 0;
        st[0] = 0;
        for(int i=1;i<=n;i++){
            while(s && num[i]>=num[st[s]]) s--;
            premx[i] = st[s]+1;
            st[++s] = i;
        }
        s = 0;
        st[0] = n+1;
        for(int i=n;i>=1;i--){
            while(s && num[i]>=num[st[s]]) s--;
            curmx[i] = st[s]-1;
            st[++s] = i;
        }

        for(int i=1;i<=n;i++) v[num[i]].push_back(i);
        int f = 0;
        for(int i=1;i<=n;i++){
            int sz = v[i].size();
            if(sz<3) continue;
            if(premx[v[i][0]]==1 && curmx[v[i][sz-1]] == n){
                for(int k=1;k<sz-1;k++){
                    int id = v[i][k];
                    if(premi[id]<=curmx[v[i][0]]+1&&curmi[id]>=premx[v[i][sz-1]]-1){
                        f = 1;
                        printf("YES\n");
                        int r = max(id+1,premx[v[i][sz-1]]);
                        ll resc = n-r+1;
                        int l = min(id-1,curmx[v[i][0]]);
                        ll resa = l;
                        printf("%lld %lld %lld\n",resa,n-resa-resc,resc);
                        break;
                    }
                }
            }
            if(f) break;
        }
        if(!f) printf("NO\n");
    }
    return 0;
}
/***
6
11
1 2 3 3 3 4 4 3 4 2 1
***/


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int f = 0;
	while(ncase--){
		f++;

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(f == 39){
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
			return 0;
		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l]) l++;
						while(lm > v[l]) l++;
						lm = v[l];
						while(v[l+1] < lm) l++;
					}
					else{
						while(rm == v[r]) r--;
						while(rm > v[r]) r--;
						rm = v[r];
						while(v[r-1] < rm) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l]) l++;
				while(lm > v[l]) l++;
				lm = v[l];
				while(v[l+1] < lm) l++;
			}
			else{
				while(rm == v[r]) r--;
				while(rm > v[r]) r--;
				rm = v[r];
				while(v[r-1] < rm) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int INF = 2e9;
const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

typedef struct Node{
	int len;
	int maxx;
} node;

node st1[maxn], st2[maxn];

int main(){

	int ncase;
	cin >> ncase;

	while(ncase--){

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		build(1, 1, n);

		v[0] = v[n+1] = INF;

		int ind = 1, cnt1 = 0, num;
		while(ind <= n){
			num = v[ind];
			while(v[ind+1] < num) ind++;
			st1[cnt1].len = ind;
			st1[cnt1++].maxx = num;
			ind++;
			while(v[ind] == num){
				st1[cnt1].len = ind;
				st1[cnt1++].maxx = num;
				ind++;
			}
		}

		ind = n; int cnt2 = 0;
		while(ind >= 1){
			num = v[ind];
			while(v[ind-1] < num) ind--;
			st2[cnt2].len = ind;
			st2[cnt2++].maxx = num;
			ind--;
			while(v[ind] == num){
				st2[cnt2].len = ind;
				st2[cnt2++].maxx = num;
				ind--;
			}
		}
		int l = 0, r = 0, res, f = 0;
		while(l < cnt1 && r < cnt1){
			if(st1[l].maxx == st2[r].maxx){
				res = getmax(1, 1, n, st1[l].len+1, st2[r].len-1);
				if(res == st1[l].maxx){
					cout << "YES" << endl;
					cout << st1[l].len << " " << st2[r].len - st1[l].len-1 << " " << n - st2[r].len + 1 << endl;
					f = 1;
					break;
				}
				else{
					if(st1[l+1].maxx == st1[l].maxx) r++;
					else if(st2[r].maxx == st2[r+1].maxx) l++;
					else if(st1[l+1].maxx < st2[r+1].maxx) l++;
					else r++;
				}
			}
			else if(st1[l].maxx < st2[r].maxx) l++;
			else r++;
		}
		if(!f) cout << "NO" << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int ff = ncase == 6 ? 1 : 0;
	int f = 0;
	while(ncase--){

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

//		if(!ff){
//			++f;
//			if(f <= 35) continue;
//			cout << "# case: " << f << endl;
//			cout << n << endl;
//			for(int i = 1; i <= n; i++) cout << v[i] << " ";
//			cout << endl;
//			continue;
//		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l] && l <= n) l++;
						while(lm > v[l] && l <= n) l++;
						lm = v[l];
						while(v[l+1] < lm && l <= n) l++;
					}
					else{
						while(rm == v[r] && r >= 0) r--;
						while(rm > v[r] && r >= 0) r--;
						rm = v[r];
						while(v[r-1] < rm && r >= 0) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l] && l <= n) l++;
				while(lm > v[l] && l <= n) l++;
				lm = v[l];
				while(v[l+1] < lm && l <= n) l++;
			}
			else{
				while(rm == v[r] && r >= 0) r--;
				while(rm > v[r] && r >= 0) r--;
				rm = v[r];
				while(v[r-1] < rm && r >= 0) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define ll long long
#define chushi(a, b) memset(a, b, sizeof(a))
#define endl "\n"
const double eps = 1e-8;
const ll INF=0x3f3f3f3f;
const int mod = 20000311;
const int maxn = 2e5 + 5;
const int N=1005;
using namespace std;

int v[maxn];
int premx[maxn], premn[maxn], sufmx[maxn], sufmn[maxn];
int top, st[maxn];

vector<int> g;
int getid(int x){
	return lower_bound(g.begin(), g.end(), x) - g.begin() + 1;
}

vector<int> m[maxn];

int main(){

	int ncase;
	cin >> ncase;

	while(ncase--){
		int n;
		cin >> n;
		for(int i = 1; i <= n; i++){
			cin >> v[i];
			g.push_back(v[i]);
			m[i].clear();
		}

		sort(g.begin(), g.end());
		g.erase(unique(g.begin(), g.end()), g.end());
		for(int i = 1; i <= n; i++) v[i] = getid(v[i]);

		top = 0; st[0] = 0;
		for(int i = 1; i <= n; i++){
			while(top && v[i] >= v[st[top]]) top--;
			premx[i] = st[top]+1;
			st[++top] = i;
		}

		top = 0; st[0] = 0;
		for(int i = 1; i <= n; i++){
			while(top && v[i] <= v[st[top]]) top--;
			premn[i] = st[top]+1;
			st[++top] = i;
		}

		top = 0; st[0] = n+1;
		for(int i = n; i >= 1; i--){
			while(top && v[i] >= v[st[top]]) top--;
			sufmx[i] = st[top]-1;
			st[++top] = i;
		}

		top = 0; st[0] = n+1;
		for(int i = n; i >= 1; i--){
			while(top && v[i] <= v[st[top]]) top--;
			sufmn[i] = st[top]-1;
			st[++top] = i;
		}

		for(int i = 1; i <= n; i++) m[v[i]].push_back(i);
		int flag = 0;
		for(int i = 1; i <= n; i++){
			int len = m[i].size();
			if(len < 3) continue;
			if(premx[m[i][0]] != 1 || sufmx[m[i][len-1]] != n) continue;
			for(int j = 1; j < len-1; j++){
				int id = m[i][j];
				if(premn[id] > sufmx[m[i][0]]+1) continue;
				if(sufmn[id] < premx[m[i][len-1]]-1) continue;
				flag = 1;

				int r = max(id+1, premx[m[i][len-1]]);
                ll resc = n - r + 1;
                int l = min(id-1, sufmx[m[i][0]]);
                ll resa = l;
                printf("YES\n");
                printf("%lld %lld %lld\n",resa,n-resa-resc,resc);
                break;
			}
			if(flag) break;
		}
		if(!flag) printf("NO\n");
	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int ff = ncase == 6 ? 1 : 0;
	int f = 0;
	while(ncase--){

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(!ff){
			++f;
			if(f <= 35) continue;
			cout << "# case: " << f << endl;
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
			continue;
		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l]) l++;
						while(lm > v[l]) l++;
						lm = v[l];
						while(v[l+1] < lm) l++;
					}
					else{
						while(rm == v[r]) r--;
						while(rm > v[r]) r--;
						rm = v[r];
						while(v[r-1] < rm) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l]) l++;
				while(lm > v[l]) l++;
				lm = v[l];
				while(v[l+1] < lm) l++;
			}
			else{
				while(rm == v[r]) r--;
				while(rm > v[r]) r--;
				rm = v[r];
				while(v[r-1] < rm) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int ff = ncase == 6 ? 1 : 0;
	int f = 0;
	while(ncase--){

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(!ff){
			cout << "# case: " << ++f << endl;
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
			continue;
		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l]) l++;
						while(lm > v[l]) l++;
						lm = v[l];
						while(v[l+1] < lm) l++;
					}
					else{
						while(rm == v[r]) r--;
						while(rm > v[r]) r--;
						rm = v[r];
						while(v[r-1] < rm) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l]) l++;
				while(lm > v[l]) l++;
				lm = v[l];
				while(v[l+1] < lm) l++;
			}
			else{
				while(rm == v[r]) r--;
				while(rm > v[r]) r--;
				rm = v[r];
				while(v[r-1] < rm) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int f = 0;
	while(ncase--){
		f++;

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(f == 39){
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l]) l++;
						while(lm > v[l]) l++;
						lm = v[l];
						while(v[l+1] < lm) l++;
					}
					else{
						while(rm == v[r]) r--;
						while(rm > v[r]) r--;
						rm = v[r];
						while(v[r-1] < rm) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l]) l++;
				while(lm > v[l]) l++;
				lm = v[l];
				while(v[l+1] < lm) l++;
			}
			else{
				while(rm == v[r]) r--;
				while(rm > v[r]) r--;
				rm = v[r];
				while(v[r-1] < rm) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int INF = 2e9;
const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

typedef struct Node{
	int len;
	int maxx;
} node;

node st1[maxn], st2[maxn];

int main(){

	int ncase;
	cin >> ncase;

	int ff = 0;
	while(ncase--){
		ff++;
		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(ff >= 22){
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
			continue;
		}

		build(1, 1, n);

		v[0] = v[n+1] = INF;

		int ind = 1, cnt1 = 0, num;
		while(ind <= n){
			num = v[ind];
			while(v[ind+1] < num) ind++;
			st1[cnt1].len = ind;
			st1[cnt1++].maxx = num;
			ind++;
			while(v[ind] == num){
				st1[cnt1].len = ind;
				st1[cnt1++].maxx = num;
				ind++;
			}
		}

		ind = n; int cnt2 = 0;
		while(ind >= 1){
			num = v[ind];
			while(v[ind-1] < num) ind--;
			st2[cnt2].len = ind;
			st2[cnt2++].maxx = num;
			ind--;
			while(v[ind] == num){
				st2[cnt2].len = ind;
				st2[cnt2++].maxx = num;
				ind--;
			}
		}
		int l = 0, r = 0, res, f = 0;
		while(l < cnt1 && r < cnt1){
			if(st1[l].maxx == st2[r].maxx){
				res = getmax(1, 1, n, st1[l].len+1, st2[r].len-1);
				if(res == st1[l].maxx){
					cout << "YES" << endl;
					cout << st1[l].len << " " << st2[r].len - st1[l].len-1 << " " << n - st2[r].len + 1 << endl;
					f = 1;
					break;
				}
				else if(st1[l+1].maxx < st2[r+1].maxx) l++;
				else r++;
			}
			else if(st1[l].maxx < st2[r].maxx) l++;
			else r++;
		}
		if(!f) cout << "NO" << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#include <vector>
using namespace std;

const int maxn = 200000 + 5;

int v[maxn];
int tree[maxn * 4];

void push_up(int node){
	tree[node] = min(tree[node<<1], tree[node<<1|1]);
}

void build(int node, int L, int R){
	if(L == R){
		tree[node] = v[L];
		return;
	}

	int mid = (L + R) >> 1;
	build(node<<1, L, mid);
	build(node<<1|1, mid+1, R);

	push_up(node);
}

int getmax(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tree[node];

	int mid = (L + R) >> 1;
	int res = 2e9;
	if(l <= mid) res = min(res, getmax(node<<1, L, mid, l, r));
	if(mid < r) res = min(res, getmax(node<<1|1, mid+1, R, l, r));

	return res;
}

int main(){

	int ncase;
	cin >> ncase;

	int ff = ncase == 6 ? 1 : 0;
	int f = 0;
	while(ncase--){

		int n;
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> v[i];

		if(!ff){
			++f;
			if(f <= 45) continue;
			cout << "# case: " << f << endl;
			cout << n << endl;
			for(int i = 1; i <= n; i++) cout << v[i] << " ";
			cout << endl;
			continue;
		}

		build(1, 1, n);

		v[0] = v[n+1] = 0;
		int l = 0, r = n+1, lm = 0, rm = 0, res;
		while(l+1 <= r){
			if(lm == rm){
				res = getmax(1, 1, n, l+1, r-1);
				if(res == lm) break;
				else{
					if(v[l] < v[r]){
						while(lm == v[l] && l <= n) l++;
						while(lm > v[l] && l <= n) l++;
						lm = v[l];
						while(v[l+1] < lm && l <= n) l++;
					}
					else{
						while(rm == v[r] && r >= 0) r--;
						while(rm > v[r] && r >= 0) r--;
						rm = v[r];
						while(v[r-1] < rm && r >= 0) r--;
					}
				}
			}
			else if(lm < rm){
				while(lm == v[l] && l <= n) l++;
				while(lm > v[l] && l <= n) l++;
				lm = v[l];
				while(v[l+1] < lm && l <= n) l++;
			}
			else{
				while(rm == v[r] && r >= 0) r--;
				while(rm > v[r] && r >= 0) r--;
				rm = v[r];
				while(v[r-1] < rm && r >= 0) r--;
			}
		}
		if(l >= r) cout << "NO" << endl;
		else{
			cout << "YES" << endl;
			cout << l << " " << r - l - 1 << " " << n - r + 1 << endl;
		}

	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<climits>
#include<functional>
#include<iomanip>
using namespace std;
#define   MP             make_pair
#define   PB             push_back
#define   endl           '\n'
#define   IOS            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define   int            long long

typedef long long LL ;

const int MOD=30, Base=998244353 ;
const int N=2e5+7 ;
//const int INF=1LL*1000*1000*1000*1000*1000*1000+7LL ;
const double pie=acos(-1.0) ;
const double EPS=1e-9 ;

int n, test, x, y, z, Left[N], Right[N], a[N] ;

int32_t main()
{
    IOS

    cin>>test  ;

    while(test--)
    {
        cin>>n ;

        x=y=z=0 ;

        for(int i=1; i<=n; ++i)
            cin>>a[i], Right[i]=Left[i]=0 ;

        Right[0]=Right[n+1]=Left[0]=Left[n+1]=0 ;

        bool pos=false ;

        multiset<int>mset ;

        for(int i=1,j=n;i<=n;++i,--j)
            Right[j]=max(Right[j+1],a[j]) , Left[i]=max(Left[i-1],a[i]) ;

        for(int i=1;i<=n;++i)
        {
            if(Left[i-1]==a[i] and Right[i+1]==a[i])
            {
                x=i-1 , y = 1 , z = n - i ;
                pos=true ;
                break ;
            }
        }

        if(!pos)
        for(int i=n-2,j=n-1;i>=1;--i)
        {

        while(j<n and Right[j]>Left[i])
            mset.insert(a[j]) , ++j ;

        if(mset.size() and *(mset.begin())>Left[i] and j<n and a[j]==Left[i] and Right[j+1]==Left[i] )
        {
            mset.insert(a[j]) , ++j ;
        }

        if(mset.size() and *(mset.begin())==Left[i] and *(mset.begin())==Right[j] )
        {
            x = i , y = j-1-i-1 , z = n-j+1 ;
            pos=true ;
        }

        if(mset.size())
        mset.insert(a[i]) ;
        else j=i ;

        }

       // cout<<" mset "<<mset.size()<<endl ;

        if(pos)
            cout<<"YES\n"<<x<<' '<<y<<' '<<z<<endl ;
        else
            cout<<"NO\n" ;

    }

    return 0;
}
/**
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<climits>
#include<functional>
#include<iomanip>
using namespace std;
#define   MP             make_pair
#define   PB             push_back
#define   endl           '\n'
#define   IOS            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define   int            long long

typedef long long LL ;

const int MOD=30, Base=998244353 ;
const int N=2e5+7 ;
//const int INF=1LL*1000*1000*1000*1000*1000*1000+7LL ;
const double pie=acos(-1.0) ;
const double EPS=1e-9 ;

int n, test, Max, x, y, z, Left[N], Right[N], a[N], l, r, Min ;

void Check()
{
    for(int i=1; i<=n; ++i)
        if(a[i]==Max and i>l and i<r)
        {
            x = i-1, y = 1, z = (n-i) ;
            break ;
        }
}

int32_t main()
{
    IOS

    cin>>test  ;

    while(test--)
    {
        cin>>n ;

        x=y=z=Max=l=r=0 ;

        Min = INT_MAX ;

        for(int i=1; i<=n; ++i)
            cin>>a[i], Right[i]=Left[i]=0, Max=max(Max, a[i]) ;

        Right[0]=Right[n+1]=Left[0]=Left[n+1]=0 ;

        map<int,int>R_idx, L_idx, Fst_L, Fst_R ;

        bool pos=false ;

        vector<int>v ;

        for(int i=1,j=n; i<=n; ++i,--j)
        {
            L_idx[i]=max(L_idx[i], a[i]) ;
            R_idx[i]=max(R_idx[i], a[i]) ;
            Left[i] =max(Left[i-1] , a[i]) ;
            Right[j]=max(Right[j+1] , a[j]) ;
            if(Fst_L[a[i]]==0)
                Fst_L[a[i]]=i ;
            if(Fst_R[a[j]]==0)
                Fst_R[a[j]]=j ;
            v.PB(a[i]) ;
        }

        l=Fst_L[Max], r=Fst_R[Max], Check() ;

        if(x)
            pos=true ;

        if(x==0)
        {
            for(int j=l; j<=r; ++j)
                Min = min(Min, a[j]) ;

            sort(v.begin(), v.end(), greater<int>()) ;

            for(int i=0; i<n; ++i)
            {
                if(Min==Left[l-1] and Min==Right[r+1])
                {
                    x=l-1, y= r-l+1, z=n-r ;
                    pos=true ;
                    break ;
                }

                //cout<<i<<' '<<Min<<" left "<<l<<" right "<<r<<endl ;

                for(int j=l; j>=Fst_L[v[i]]; --j)
                    Min = min(Min, a[j]) ;

                for(int j=r; j<=Fst_R[v[i]]; ++j)
                    Min = min(Min, a[j]) ;

                l=min( l, Fst_L[v[i]]) ;
                r=max( r, Fst_R[v[i]]) ;
            }
        }

        if(pos)
            cout<<"YES\n"<<x<<' '<<y<<' '<<z<<endl ;
        else
            cout<<"NO\n" ;

    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<climits>
#include<functional>
#include<iomanip>
using namespace std;
#define   MP             make_pair
#define   PB             push_back
#define   endl           '\n'
#define   IOS            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define   int            long long

typedef long long LL ;

const int MOD=30, Base=998244353 ;
const int N=2e5+7 ;
//const int INF=1LL*1000*1000*1000*1000*1000*1000+7LL ;
const double pie=acos(-1.0) ;
const double EPS=1e-9 ;

int n, test, Max, x, y, z, Left[N], Right[N], a[N], l, r, Min ;

void Check()
{
    for(int i=1; i<=n; ++i)
        if(a[i]==Max and i>l and i<r)
        {
            x = i-1, y = 1, z = (n-i) ;
            break ;
        }
}

int32_t main()
{
    IOS

    cin>>test  ;

    while(test--)
    {
        cin>>n ;

        x=y=z=Max=l=r=0 ;

        Min = INT_MAX ;

        for(int i=1; i<=n; ++i)
            cin>>a[i], Right[i]=Left[i]=0, Max=max(Max, a[i]) ;

        Right[0]=Right[n+1]=Left[0]=Left[n+1]=0 ;

        map<int,int>R_idx, L_idx, Fst_L, Fst_R ;

        bool pos=false ;

        vector<int>v ;

        for(int i=1,j=n; i<=n; ++i,--j)
        {
            L_idx[i]=max(L_idx[i], a[i]) ;
            R_idx[i]=max(R_idx[i], a[i]) ;
            Left[i] =max(Left[i-1] , a[i]) ;
            Right[j]=max(Right[j+1] , a[j]) ;
            if(Fst_L[a[i]]==0)
                Fst_L[a[i]]=i ;
            if(Fst_R[a[j]]==0)
                Fst_R[a[j]]=j ;
            v.PB(a[i]) ;
        }

        l=Fst_L[Max], r=Fst_R[Max], Check() ;

        if(x)
            pos=true ;

        if(x==0)
        {
            for(int j=l; j<=r; ++j)
                Min = min(Min, a[j]) ;

            sort(v.begin(), v.end(), greater<int>()) ;

            for(int i=0; i<n; ++i)
            {
                if(Min==Left[l-1] and Min==Right[r+1])
                {
                    x=l-1, y= r-l+1, z=n-r ;
                    pos=true ;
                    break ;
                }

                if(Min>a[l-1] and l>=2 and a[l-1]==Left[l-2] and Right[r+1]==a[l-1])
                {
                   l-- , x=l-1 , y= r-l+1 , z=n-r ;
                   pos=true ;
                   break ;
                }

                if(Min>a[r+1] and n-2>=r and a[r+1]==Right[r+2] and Left[l-1]==a[r+1] )
                {
                    r++ , x=l-1 , y= r-l+1 , z=n-r ;
                    pos=true ;
                    break ;
                }

                //cout<<i<<' '<<Min<<" left "<<l<<" right "<<r<<endl ;

                for(int j=l; j>=Fst_L[v[i]]; --j)
                    Min = min(Min, a[j]) ;

                for(int j=r; j<=Fst_R[v[i]]; ++j)
                    Min = min(Min, a[j]) ;

                l=min( l, Fst_L[v[i]]) ;
                r=max( r, Fst_R[v[i]]) ;
            }
        }

        if(pos)
            cout<<"YES\n"<<x<<' '<<y<<' '<<z<<endl ;
        else
            cout<<"NO\n" ;

    }

    return 0;
}
/**
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<climits>
#include<functional>
#include<iomanip>
using namespace std;
#define   MP             make_pair
#define   PB             push_back
#define   endl           '\n'
#define   IOS            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define   int            long long

typedef long long LL ;

const int MOD=30, Base=998244353 ;
const int N=2e5+7 ;
//const int INF=1LL*1000*1000*1000*1000*1000*1000+7LL ;
const double pie=acos(-1.0) ;
const double EPS=1e-9 ;

int n, test, x, y, z, Left[N], Right[N], a[N] ;

int32_t main()
{
    IOS

    cin>>test  ;

    while(test--)
    {
        cin>>n ;

        x=y=z=0 ;

        for(int i=1; i<=n; ++i)
            cin>>a[i], Right[i]=Left[i]=0 ;

        Right[0]=Right[n+1]=Left[0]=Left[n+1]=0 ;

        bool pos=false ;

        multiset<int>mset ;

        for(int i=1,j=n;i<=n;++i,--j)
            Right[j]=max(Right[j+1],a[j]) , Left[i]=max(Left[i-1],a[i]) ;

        for(int i=1;i<=n;++i)
        {
            if(Left[i-1]==a[i] and Right[i+1]==a[i])
            {
                x=i-1 , y = 1 , z = n - i ;
                pos=true ;
                break ;
            }
        }

        if(!pos)
        for(int i=n-2,j=n-1;i>=1;--i)
        {

        while(j<n and Right[j]>Left[i])
            mset.insert(a[j]) , ++j ;

        if(mset.size() and *(mset.begin())>Left[i] and j<n and a[j]==Left[i] and Right[j+1]==Left[i] )
        {
            mset.insert(a[j]) , ++j ;
        }

        if(mset.size() and *(mset.begin())==Left[i] and *(mset.begin())==Right[j] )
        {
            x = i , y = j-1-i , z = n-j+1 ;
            pos=true ;
        }

        if(mset.size())
        mset.insert(a[i]) ;
        else j=i ;

        }

       // cout<<" mset "<<mset.size()<<endl ;

        if(pos)
            cout<<"YES\n"<<x<<' '<<y<<' '<<z<<endl ;
        else
            cout<<"NO\n" ;

    }

    return 0;
}
/**
1
10
6 1 4 1 6 7 1 3 6 3
*/


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][30];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	l = 1,r = n;
	while(l < r - 1) {
		while(lmax[l] != rmax[r] && l < r - 1) {
			if(lmax[l] < rmax[r]) l++;
			else r--;
		}
		if(l >= r - 1) break;
		if(lmax[l] == rmax[r] && lmax[l] == find(l + 1,r - 1)) {
			cout<<"YES"<<endl;
			cout<<l<<" "<<r - l - 1<<" "<<n + 1 - r<<endl;
			return;
		}

		if(val[l + 1] < lmax[l])l++;
		else if(val[r - 1] < rmax[r])r--;
		else if(val[l + 1] == lmax[l])l++;
		else if(val[r - 1] == rmax[r])r--;
		else if(val[r - 1] < val[l + 1]) r--;
		else if(val[r - 1] > val[l + 1]) l++;
		else l++,r--;
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i)
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);

		work();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][30];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	l = 1,r = n;
	while(l < r - 1) {
		while(lmax[l] != rmax[r] && l < r - 1) {
			if(lmax[l] < rmax[r]) l++;
			else r--;
		}
		if(l >= r - 1) break;
		if(lmax[l] == rmax[r] && lmax[l] == find(l + 1,r - 1)) {
			cout<<"YES"<<endl;
			cout<<l<<" "<<r - l - 1<<" "<<n + 1 - r<<endl;
			return;
		}

		if(val[l + 1] < val[r - 1])l++;
		else r--;
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i)
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);

		work();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][30];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	for(int i = 1;i < n - 1;i++) {
		int max1 = lmax[i];
		int l = i + 1,r = n - 1,m;
        while(l <= r){
            m = (l + r) / 2;
            int min2 = find(i + 1,m),max3 = rmax[m + 1];
            if(max1 < min2 || max1 < max3) l = m + 1;
            else if(max1 > min2 || max1 > max3) r = m - 1;
            else {
                puts("YES");
                cout<<i<<" "<<m - i<<" "<<n - m<<endl;
                return;
            }
        }
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i)
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);

		work();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][20];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	l = 1,r = n;
	while(l < r - 1) {
		while(lmax[l] != rmax[r] && l < r - 1) {
			if(lmax[l] < rmax[r]) l++;
			else r--;
		}
		if(l >= r - 1) break;
		if(lmax[l] == rmax[r] && lmax[l] == find(l + 1,r - 1)) {
			cout<<"YES"<<endl;
			cout<<l<<" "<<r - l - 1<<" "<<n + 1 - r<<endl;
			return;
		}
		//cout<<l<<" "<<r<<" "<<lmax[l + 1]<<" "<<rmax[r - 1]<<endl;
		if(val[l + 1] < val[r - 1])l++;
		else if(val[l + 1] > val[r - 1])r--;
		else r--;
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i) {
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);
			}

		work();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][30];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	for(int i = 1;i < n - 1;i++) {
		int l = i + 1,r = n,m;
		while(l <= r) {
			m = (l + r + 1) / 2;
			//cout<<l<<" "<<r<<" "<<m<<" "<<find(i + 1,m - 1)<<" "<<rmax[m]<<endl;
			if(rmax[m] > lmax[i]) l = m + 1;
			else if(rmax[m] < lmax[i]) r = m - 1;
			else if(find(i + 1,m - 1) < lmax[i]) r = m - 1;
			else if(find(i + 1,m - 1) > lmax[i]) l = m + 1;
			else {
				cout<<"YES"<<endl;
				cout<<i<<" "<<m - i - 1<<" "<<n + 1 - m<<endl;
				return;
			}
		}
		m = l + 1;
		if(rmax[m] == lmax[i] && find(i + 1,m - 1) == lmax[i])
		{
			cout<<"YES"<<endl;
				cout<<i<<" "<<m - i - 1<<" "<<n + 1 - m<<endl;
				return;
		}
			m = l;
		if(rmax[m] == lmax[i] && find(i + 1,m - 1) == lmax[i])
		{
			cout<<"YES"<<endl;
				cout<<i<<" "<<m - i - 1<<" "<<n + 1 - m<<endl;
				return;
		}
			m = l - 1;
		if(rmax[m] == lmax[i] && find(i + 1,m - 1) == lmax[i])
		{
			cout<<"YES"<<endl;
				cout<<i<<" "<<m - i - 1<<" "<<n + 1 - m<<endl;
				return;
		}
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i)
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);

		work();
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 1100000
long long t,n,x,num,val;
void work(long long x)
{
	num = 1;
	val = x;
	for(long long i = 2;i * i <= x;++i)
		if(x % i == 0) {
			long long tmp_num = 0;
			while(x % i == 0) x /= i,tmp_num++;
			if(tmp_num > num) num = tmp_num,val = i;
		}
}

int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		work(n);
		cout<<num<<endl;
		for(long long i = 1;i < num;++i) cout<<val<<" ";
		while(n % (val * val) == 0) n /= val;
		cout<<n<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200010
int t,n,l,r,val[N],lmax[N],rmax[N],mmin[N][30];
int find(int l,int r)
{
	int len = 1;
	while((1 << len) <= r - l)len++;
	len--;
	return min(mmin[l][len],mmin[r - (1 << len) + 1][len]);
}
void work()
{
	for(int i = 1;i < n - 1;i++) {
		int l = i + 1,r = n,m;
		while(l <= r) {
			m = (l + r + 1) / 2;
			//cout<<l<<" "<<r<<" "<<m<<" "<<find(i + 1,m - 1)<<" "<<rmax[m]<<endl;
			if(rmax[m] > lmax[i]) l = m + 1;
			else if(rmax[m] < lmax[i]) r = m - 1;
			else if(find(i + 1,m - 1) < lmax[i]) r = m - 1;
			else if(find(i + 1,m - 1) > lmax[i]) l = m + 1;
			else {
				cout<<"YES"<<endl;
				cout<<i<<" "<<m - i - 1<<" "<<n + 1 - m<<endl;
				return;
			}
		}
	}
	cout<<"NO"<<endl;
}
int main()
{
	cin>>t;
	while(t--) {
		cin>>n;
		rmax[n + 1] = 0;
		for(int i = 1;i <= n;++i) cin>>val[i],mmin[i][0] = val[i];
		for(int i = 1;i <= n;++i) lmax[i] = max(lmax[i - 1],val[i]);
		for(int i = n;i >= 1;--i) rmax[i] = max(rmax[i + 1],val[i]);

		for(int l = 1;(1 << l) <= n;++l)
			for(int i = 1;i + (1 << l)  - 1 <= n;++i)
				mmin[i][l] = min(mmin[i][l - 1],mmin[i + (1 << (l - 1))][l - 1]);

		work();
	}

	return 0;
}


#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;

struct segtree{
	ll size;
	vector<ll>mini;
	segtree(ll n,vector<ll>&a){
		size=1;
		while(size<n){
			size*=2;
		}
		mini.resize(2*size,INF); //total 2n+2n-1 elements for the whole tree to store it in array based form.
		build(a);
	}

	void build(vector<ll>&a){
		build(0,0,size,a);
	}
	void build(ll x,ll l,ll r,vector<ll>&a){ // Here l,r means segment from index l to r-1.
		if(r-l==1){
			if(l<(ll)a.size()){
				mini[x]=a[l];
			}
			return;
		}
		ll m=l+(r-l)/2;
		build(2*x+1,l,m,a);
		build(2*x+2,m,r,a);
		mini[x]=min(mini[2*x+1],mini[2*x+2]);
	}

	ll calc(ll l,ll r){
		return calc(0,0,size,l,r);
	}
	ll calc(ll x,ll lx,ll rx,ll l,ll r){
		if(rx<=l||r<=lx){
			return INF;
		}
		if(lx>=l && rx<=r){
			return mini[x];
		}
		ll m=lx+(rx-lx)/2;
		ll ans=min(calc(2*x+1,lx,m,l,r),calc(2*x+2,m,rx,l,r));
		return ans;
	}
};

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);
		for(auto &ele:a){
			cin>>ele;
		}
		segtree sg(n,a);
		vector<ll>pref(n),suff(n);
		pref[0]=a[0];
		suff[n-1]=a[n-1];
		for(ll i=1;i<n;i++){
			pref[i]=max(a[i],pref[i-1]);
		}
		for(ll i=n-2;i>=0;i--){
			suff[i]=max(a[i],suff[i+1]);
		}
		bool ans=0;
		for(ll i=0;i<n-2;i++){
			ll now=pref[i];
			ll l=i+2,r=n-1;
			while(l<=r){
				ll m=l+(r-l)/2;
				if(suff[m]==now){
					ll x=sg.calc(i+1,m);
					if(x==now){
						cout<<"YES\n";
						cout<<i+1<<" "<<m-i-1<<" "<<n-m<<"\n";
						ans=1;
						break;
					}
					if(x<now){
						r=m-1;
					}
					else{
						l=m+1;
					}
					continue;
				}
				if(suff[m]<now){
					r=m-1;
				}
				else{
					l=m+1;
				}
			}
			if(ans){
				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

	ll t;
	cin>>t;
	for(ll x=1;x<=t;x++){
		ll n;
		cin>>n;
		vector<ll>a(n);
		set<pair<ll,ll>>st;
		for(auto &ele:a){
			cin>>ele;
		}
		if(x==721){
			cout<<n<<"\n";
			for(ll i=1;i<=n;i++){
				cout<<a[i]<<" ";
			}
			cout<<"\n";
			break;
		}
		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(a[l+1]<=a[r-1]){
					l++;
					st.erase({a[l],l});
				}
				else{
					r--;
					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>
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;

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(a[l+1]<=a[r-1]){
					l++;
					st.erase({a[l],l});
				}
				else{
					r--;
					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>
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;
	for(ll x=1;x<=t;x++){
		ll n;
		cin>>n;
		vector<ll>a(n);
		set<pair<ll,ll>>st;
		for(auto &ele:a){
			cin>>ele;
		}
		if(x==721){
			for(ll i=1;i<=n;i++){
				cout<<a[i]<<" ";
			}
			cout<<"\n";
			break;
		}
		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>
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++){
			st.erase({a[l],l});
			while(r<=l+1){
				st.insert({a[r],r});
				r++;
			}
			while(r>l+1 && suff[r]<=pref[l]){
				st.erase({a[r],r});
				r--;
			}
			r++;
			if(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]==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;

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(a[l+1]<m1){
					l++;
					st.erase({a[l],l});

				}
				else if(a[r-1]<m1){
					r--;
					st.erase({a[r],r});
				}
				else{
					if(a[l+1]<=a[r-1]){
						r--;
						st.erase({a[r],r});
					}
					else{
						l++;
						st.erase({a[l],l});
					}
				}
			}
			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>
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;
	for(ll x=1;x<=t;x++){
		ll n;
		cin>>n;
		vector<ll>a(n);
		set<pair<ll,ll>>st;
		for(auto &ele:a){
			cin>>ele;
		}
		if(x==721){
			for(ll i=1;i<=n;i++){
				cout<<a[i]<<" ";
			}
			cout<<"\n";
			break;
		}
		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(a[l+1]<=a[r-1]){
					l++;
					st.erase({a[l],l});
				}
				else{
					r--;
					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>
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;
	for(ll x=1;x<=t;x++){
		ll n;
		cin>>n;
		vector<ll>a(n);
		set<pair<ll,ll>>st;
		for(auto &ele:a){
			cin>>ele;
		}
		if(t==20000 && x==721){
			cout<<n<<"\n";
			for(auto ele:a){
				cout<<ele<<" ";
			}
			cout<<"\n";
			break;
		}
		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){
					if(t!=20000){
						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(t==20000){
			continue;
		}
		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;

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(a[l+1]<m1){
					l++;
					st.erase({a[l],l});
				}
				else if(a[r-1]<m1){
					r--;
					st.erase({a[r],r});
				}
				else{
					if(ele<m1){
						l++;
						r--;
						st.erase({a[l],l});
						st.erase({a[r],r});
					}
					else{
						if(a[l+1]<=a[r-1]){
							l++;
							st.erase({a[l],l});
						}
						else{
							r--;
							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>
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;

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(a[l+1]<m1){
					l++;
					st.erase({a[l],l});
				}
				else if(a[r-1]<m1){
					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";
		}
	}
}