//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    sortv(a);
    ll ans=0;
    for(int i=1;i<n;i++){
        ll temp=a[i]-a[0];
        if(temp%2==1) ans++;
    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define um unordered_map
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
   in(n);
   read(a,n);
   int odd=0;
   forr(i,n){
        if(a[i]%2==1) odd++;
   }
   int even=n-odd;
   oo(min(odd,even));

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    ll odd=0;
    forr(i,n){
        if(abs(a[i])&1) odd++;
    }
    ll even=n-odd;
    oo(min(odd,even));

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    ll ans=0;
    for(int i=1;i<n;i++){
        if(abs(a[i]-a[0])&1) ans++;
    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    umii mp;
    forr(i,n){
        mp[a[i]]++;
    }
    ll most=-1;
    ll val;
    go(mp){
        if(v>most){
            val=u;
            most=v;
        }
    }
    ll ans=0;
    forr(i,n){
        if(a[i]!=val){
            ll temp=abs(a[i]-val);
            if(temp%2==1) ans++;
        }
    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    unordered_map<ll,ll> mp;
    forr(i,n){
        mp[a[i]]++;
    }
    ll most=-1;
    ll val;
    go(mp){
        if(v>most){
            val=u;
            most=v;
        }
    }
    //db(val);
    ll ans=0;
    forr(i,n){
        if(a[i]==val) cc;
        ll temp=abs(a[i]-val);
        if(temp%2==1) ans+=temp;

    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    umii mp;
    forr(i,n){
        mp[a[i]]++;
    }
    ll most=-1;
    ll val;
    go(mp){
        if(v>most){
            val=u;
            most=v;
        }
    }
    ll ans=0;
    forr(i,n){
        if(a[i]!=val){
            ll temp=a[i]-val;
            if(temp%2==1) ans++;
        }
    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n"
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    read(a,n);
    unordered_map<ll,ll> mp;
    forr(i,n){
        mp[a[i]]++;
    }
    ll most=-1;
    ll val;
    go(mp){
        if(v>most){
            val=u;
            most=v;
        }
    }
    //db(val);
    ll ans=0;
    forr(i,n){
        if(a[i]==val) cc;
        ll temp=abs(a[i]-val);
        if(temp%2==1) ans++;

    }
    oo(ans);

}

int main(){
     #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
   freopen("output1.txt", "w", stdout);
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if ((a[i] - mn) % 2 != 0) {
                ans ++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5, mx = 0;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
        mx = max (mx, a[i]);
    }
    ll ans = 0, ans1 = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if ((a[i] - mn) % 2 != 0) {
                ans ++;
            }
        }
    }
    rep(i, n) {
        if (a[i] != mn) {
            if ((mn - a[i]) % 2 != 0) {
                ans1 ++;
            }
        }
    }
    cout << min(ans1, ans);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5, mx = 0;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
        mx = max (mx, a[i]);
    }
    ll ans = 0, ans1 = 0;

    rep(i, n) {
        if (a[i] != mn) {
            if ((mn - a[i]) % 2 != 0) {
                ans1 ++;
            }
        }
    }
    cout << ans1;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if (a[i] % 2 == mn) {
                continue;
            }
            else {
                ans ++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if ((a[i] - mn) % 2 != 0) {
            ans ++;
        }
    }
    cout << min(n - ans, ans);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5, mx = 0;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
        mx = max (mx, a[i]);
    }
    sort(a, a + n);
    ll ans = 0, ans1 = 0;
    rep(i, n) {
        if ((a[i] - mn) % 2 != 0) {
            ans ++;
        }
    }
    rep(i, n) {
        if ((mx - a[i]) % 2 != 0) {
            ans1 ++;
        }
    }
    cout << min(ans1, ans);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5, mx = 0;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
        mx = max (mx, a[i]);
    }
    ll ans = 0, ans1 = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if ((a[i] - mn) % 2 != 0) {
                ans ++;
            }
        }
    }
    rep(i, n) {
        if (a[i] != mx) {
            if ((mx - a[i]) % 2 != 0) {
                ans1 ++;
            }
        }
    }
    cout << min(ans1, ans);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if (a[i] % 2 == 0) {
                continue;
            }
            else {
                ans ++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if ((a[i] - mn) % 2 == 0) {
                continue;
            }
            else {
                ans ++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5, mx = 0;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
        mx = max (mx, a[i]);
    }
    ll ans = 0, ans1 = 0;
    rep(i, n) {
        if (abs(a[i] - mn) % 2 != 0) {
            ans ++;
        }
    }
    rep(i, n) {
        if (abs(mx - a[i]) % 2 != 0) {
            ans1 ++;
        }
    }
    cout << min(ans1, ans);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < n; i ++)
#define speed ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int inf = 1e9;
const int N = 1e6;

ll a[N];

int main(){
    speed
    int n;
    cin >> n;
    ll mn = 1e9 * 5;
    rep(i, n) {
        cin >> a[i];
        mn = min (mn, a[i]);
    }
    ll ans = 0;
    rep(i, n) {
        if (a[i] != mn) {
            if (a[i] % mn == 0) {
                continue;
            }
            else {
                ans ++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i< n;i++)
    {
        cin>>arr[i];
    }
    int ans= INT_MAX;
    for(int i=0;i<n;i++)
    {
        int minz=0;
        for(int j=0;j<n;j++)
        {
            if((arr[i]-arr[j])%2)
                minz++;
        }
        ans=min(ans,minz);
        minz=0;
    }
    cout<<ans<<endl;
}


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

int
main ()
{
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  sort (arr, arr + n);
  int maxLength = 1;
  int index = 0;
  int curr_count = 1;
  for (int i = 1; i < n; i++)
    {
        if (arr[i] == arr[i - 1])
	        curr_count++;
        else
	    {
	        if (curr_count > maxLength)
	        {
	            maxLength = curr_count;
	            index = i - 1;
	        }
	        curr_count = 1;
	    }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
    	if ((abs (arr[index] - arr[i]) % 2))
    	    ans++;
    }
  cout << ans << endl;
  return 0;
}


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

int
main ()
{
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  sort (arr, arr + n);
  int maxLength = 1;
  int index = -1;
  int res = arr[0], curr_count = 1;
  for (int i = 1; i < n; i++)
    {
      if (arr[i] == arr[i - 1])
	curr_count++;
      else
	{
	  if (curr_count > maxLength)
	    {
	      maxLength = curr_count;
	      res = arr[i - 1];
	      index = i - 1;
	    }
	  curr_count = 1;
	}
    }
  int ans = 0;
  if (maxLength == 1)
    {
      for (int i = 1; i < n; i++)
	{
	  if ((abs (arr[0] - arr[i]) % 2))
	    ans= ans+abs (arr[0] - arr[i]);
	}
    }
  else
    {
      for (int i = 0; i < n; i++)
	{
	  if ((abs (arr[index] - arr[i]) % 2))
	    ans=ans+abs (arr[index] - arr[i]);
	}
    }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	sort(arr,arr+n);
	int maxLength=1;
	int index=-1;
	int res = arr[0], curr_count = 1;
    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i - 1])
            curr_count++;
        else {
            if (curr_count > maxLength) {
                maxLength = curr_count;
                res = arr[i - 1];
                index=i-1;
            }
            curr_count = 1;
        }
    }
	int ans=0;
	if(maxLength==1)
	{
	    for(int i=1;i<n;i++)
	    {
	        if((abs(arr[0]-arr[i])%2))
	            ans++;
	    }
	}
	else
	{
	    for(int i=0;i<n;i++)
	    {
	        if((abs(arr[index]-arr[i])%2))
	            ans++;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	sort(arr,arr+n);
	int maxLength=1;
	int index=-1;
	for(int i=0;i<n-1;i++)
	{
	    if(arr[i]==arr[i+1])
	    {
	        maxLength++;
	        index=i;
	    }

	}
	int ans=0;
	if(maxLength==1)
	{
	    for(int i=1;i<n;i++)
	    {
	        if((abs(arr[0]-arr[i])%2))
	            ans++;
	    }
	}
	else
	{
	    for(int i=0;i<n;i++)
	    {
	        if((abs(arr[index]-arr[i])%2))
	            ans++;
	    }
	}
	cout<<ans<<endl;
	return 0;
}


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

int
main ()
{
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  sort (arr, arr + n);
  int maxLength = 1;
  int index = -1;
  int res = arr[0], curr_count = 1;
  for (int i = 1; i < n; i++)
    {
      if (arr[i] == arr[i - 1])
	curr_count++;
      else
	{
	  if (curr_count > maxLength)
	    {
	      maxLength = curr_count;
	      res = arr[i - 1];
	      index = i - 1;
	    }
	  curr_count = 1;
	}
    }
  int ans = 0;
  if (maxLength == 1)
    {
      for (int i = 1; i < n; i++)
	{
	  if ((abs (arr[0] - arr[i]) % 2))
	    ans= ans+(abs (arr[0] - arr[i])%2);
	}
    }
  else
    {
      for (int i = 0; i < n; i++)
	{
	  if ((abs (arr[index] - arr[i]) % 2))
	    ans=ans+(abs (arr[index] - arr[i])%2);
	}
    }
  cout << ans << endl;
  return 0;
}


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

int main ()
{
  int n; cin>>n;

          int a[n];

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

          int ans=INT_MAX,tmpans=0;

          for(int i=0;i<n;i++) {
            tmpans=0;

            for(int j=0;j<n;j++) {
              if(a[i]==a[j]) continue;

              if(abs(a[i]-a[j])%2) tmpans++;
            }
            ans = min(ans,tmpans);
          }

          cout<<ans<<endl;

      return 0;
  }


#include <bits/stdc++.h>

#define fi first
#define se second
#define pp pop_back
#define ll long long
#define pb push_back
#define ld long double
#define debug cout << "OK\n";
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e5 + 200;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void data()
{
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}

int tt, n, t[N * 4], t2[N * 4];
void upd(int pos, int val, int v = 1, int tl = 1, int tr = N)
{
	if (tl == tr)
	{
		t[v] = val;
		t2[v] = val;

		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm)
	{
		upd(pos, val, v * 2, tl, tm);
	}
	else
	{
		upd(pos, val, v * 2 + 1, tm + 1, tr);
	}
	t[v] = max(t[v + v], t[v + v + 1]);
	t2[v] = min(t2[v + v], t2[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t[v];
	}
	if (l > tr || r < tl)
	{
		return -1e9;
	}
	int tm = (tl + tr) / 2;
	return max(get(l, r, v * 2, tl, tm), get(l, r ,v * 2 + 1, tm + 1, tr));
}
int get2(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t2[v];
	}
	if (l > tr || r < tl)
	{
		return 1e9;
	}
	int tm = (tl + tr) / 2;
	return min(get2(l, r, v * 2, tl, tm), get2(l, r ,v * 2 + 1, tm + 1, tr));
}
main()
{
	data();
	ios::sync_with_stdio(false);
   	cin.tie(0);
    cin >> tt;
    while (tt--)
    {
		int n;
		cin >> n;
		int a[n + 1];
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			upd(i, a[i]);
		}
		int mx = 0, ok = 0;;
		for (int i = 1; i <= n - 2; i++)
		{
			mx = max(mx, a[i]);
			int l = i + 2, r = n;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (get(mid, n) == mx)
				{
					r = mid - 1;
				}
				else
				{
					l = mid + 1;
				}
			}
			if (get(l, n) == mx && get2(i + 1, l - 1) == mx && (n - l + 1) + i + (l - 1) - (i + 1) + 1 == n)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (l - 1) - (i + 1) + 1 << " " << (n - l + 1) << '\n';
				break;
			}
		}
		if (ok)
		{
			continue;
		}
		cout << "NO\n";
    }
}
/*
*/


#include <bits/stdc++.h>

#define fi first
#define se second
#define pp pop_back
#define ll long long
#define pb push_back
#define ld long double
#define debug cout << "OK\n";
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e6 + 200;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void data()
{
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}

int tt, n, t[N * 4], t2[N * 4];
void upd(int pos, int val, int v = 1, int tl = 1, int tr = N)
{
	if (tl == tr)
	{
		t[v] = val;
		t2[v] = val;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm)
	{
		upd(pos, val, v * 2, tl, tm);
	}
	else
	{
		upd(pos, val, v * 2 + 1, tm + 1, tr);
	}
	t[v] = max(t[v + v], t[v + v + 1]);
	t2[v] = min(t2[v + v], t2[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t[v];
	}
	if (l > tr || r < tl)
	{
		return -INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return max(get(l, r, v * 2, tl, tm), get(l, r ,v * 2 + 1, tm + 1, tr));
}
int get2(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t2[v];
	}
	if (l > tr || r < tl)
	{
		return INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return min(get2(l, r, v * 2, tl, tm), get2(l, r ,v * 2 + 1, tm + 1, tr));
}
main()
{
	data();
	ios::sync_with_stdio(false);
   	cin.tie(0);
    cin >> tt;
    while (tt--)
    {
		int n;
		cin >> n;
		int a[n + 1];
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			upd(i, a[i]);
		}
		int mx = 0, ok = 0;;
		for (int i = 1; i <= n; i++)
		{
			mx = max(mx, a[i]);
			int l = i + 2, r = n;
			int answer = 0;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (get(mid, n) == mx)
				{
					r = mid - 1;
					answer = mid;
				}
				else
				{
					l = mid + 1;
				}
			}
			if (get(answer, n) == mx && get2(i + 1, answer - 1) == mx && (n - answer + 1) + i + (answer - 1) - (i + 1) + 1 == n && (answer - 1) - (i + 1) + 1 >= 1 && (n - answer + 1) >= 1)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (answer - 1) - (i + 1) + 1 << " " << (n - answer + 1) << '\n';
				break;
			}
		}
		if (ok)
		{
			continue;
		}
		cout << "NO\n";
    }
}
/*
*/


#include <bits/stdc++.h>

#define fi first
#define se second
#define pp pop_back
#define ll long long
#define pb push_back
#define ld long double
#define debug cout << "OK\n";
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e6 + 200;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void data()
{
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}

int tt, n, t[N * 4], t2[N * 4];
void upd(int pos, int val, int v = 1, int tl = 1, int tr = N)
{
	if (tl == tr)
	{
		t[v] = val;
		t2[v] = val;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm)
	{
		upd(pos, val, v * 2, tl, tm);
	}
	else
	{
		upd(pos, val, v * 2 + 1, tm + 1, tr);
	}
	t[v] = max(t[v + v], t[v + v + 1]);
	t2[v] = min(t2[v + v], t2[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t[v];
	}
	if (l > tr || r < tl)
	{
		return -INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return max(get(l, r, v * 2, tl, tm), get(l, r ,v * 2 + 1, tm + 1, tr));
}
int get2(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t2[v];
	}
	if (l > tr || r < tl)
	{
		return INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return min(get2(l, r, v * 2, tl, tm), get2(l, r ,v * 2 + 1, tm + 1, tr));
}
main()
{
	data();
	ios::sync_with_stdio(false);
   	cin.tie(0);
    cin >> tt;
    while (tt--)
    {
		int n;
		cin >> n;
		for (int i = 1; i <= n * 4; i++)
		{
			t[i] = 0, t2[i] = 0;
		}
		int a[n + 1];
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			upd(i, a[i]);
		}
		int mx = 0, ok = 0;;
		for (int i = 1; i <= n; i++)
		{
			mx = max(mx, a[i]);
			int l = i + 2, r = n;
			int answer = 0;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (get(mid, n) > mx)
				{
					l = mid + 1;
					continue;
				}
				if (get(mid, n) < mx)
				{
					r = mid - 1;
					continue;
				}
				if (get2(i + 1, mid) > mx)
				{
					l = mid + 1;
					continue;
				}
				if (get2(i + 1, mid) < mx)
				{
					r = mid - 1;
					continue;
				}
				if ((n - mid - 1) > 0 && (mid - i + 1) > 0)
				{
					cout << "YES\n";
					cout << i << " " << (mid - i + 1) << " " << (n - mid - 1) << '\n';
					answer = 1;
					break;
				}
				r = mid - 1;
			}
			if (answer == 1)
			{
				ok = 1;
				break;
			}
			answer = l;
			if (get(answer, n) == mx && get2(i + 1, answer - 1) == mx && (n - answer + 1) + i + (answer - 1) - (i + 1) + 1 == n && (answer - 1) - (i + 1) + 1 >= 1 && (n - answer + 1) >= 1)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (answer - 1) - (i + 1) + 1 << " " << (n - answer + 1) << '\n';
				break;
			}
			answer = r;
			if (get(answer, n) == mx && get2(i + 1, answer - 1) == mx && (n - answer + 1) + i + (answer - 1) - (i + 1) + 1 == n && (answer - 1) - (i + 1) + 1 >= 1 && (n - answer + 1) >= 1)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (answer - 1) - (i + 1) + 1 << " " << (n - answer + 1) << '\n';
				break;
			}
		}
		if (ok)
		{
			continue;
		}
		cout << "NO\n";
    }
}
/*
*/


#include <bits/stdc++.h>

#define fi first
#define se second
#define pp pop_back
#define ll long long
#define pb push_back
#define ld long double
#define debug cout << "OK\n";
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e6 + 200;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

void data()
{
	#ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}

int tt, n, t[N * 4], t2[N * 4];
void upd(int pos, int val, int v = 1, int tl = 1, int tr = N)
{
	if (tl == tr)
	{
		t[v] = val;
		t2[v] = val;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm)
	{
		upd(pos, val, v * 2, tl, tm);
	}
	else
	{
		upd(pos, val, v * 2 + 1, tm + 1, tr);
	}
	t[v] = max(t[v + v], t[v + v + 1]);
	t2[v] = min(t2[v + v], t2[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t[v];
	}
	if (l > tr || r < tl)
	{
		return -INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return max(get(l, r, v * 2, tl, tm), get(l, r ,v * 2 + 1, tm + 1, tr));
}
int get2(int l, int r, int v = 1, int tl = 1, int tr = N)
{
	if (l <= tl && tr <= r)
	{
		return t2[v];
	}
	if (l > tr || r < tl)
	{
		return INT_MAX;
	}
	int tm = (tl + tr) / 2;
	return min(get2(l, r, v * 2, tl, tm), get2(l, r ,v * 2 + 1, tm + 1, tr));
}
main()
{
	data();
	ios::sync_with_stdio(false);
   	cin.tie(0);
    cin >> tt;
    while (tt--)
    {
		int n;
		cin >> n;
		for (int i = 1; i <= n * 4; i++)
		{
			t[i] = 0, t2[i] = 0;
		}
		int a[n + 1];
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			upd(i, a[i]);
		}
		int mx = 0, ok = 0;;
		for (int i = 1; i <= n; i++)
		{
			mx = max(mx, a[i]);
			int l = i + 2, r = n;
			int answer = 0;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (get(mid, n) > mx)
				{
					l = mid + 1;
					continue;
				}
				if (get(mid, n) < mx)
				{
					r = mid - 1;
					continue;
				}
				if (get2(i + 1, mid) > mx)
				{
					l = mid + 1;
					continue;
				}
				if (get2(i + 1, mid) < mx)
				{
					r = mid - 1;
					continue;
				}
				if ((n - mid - 1) > 0 && (mid - i + 1) > 0)
				{
					cout << "YES\n";
					cout << i << " " << (mid - i + 1) << " " << (n - mid - 1) << '\n';
					answer = 1;
					break;
				}
				l = mid + 1;
			}
			if (answer == 1)
			{
				ok = 1;
				break;
			}
			answer = l;
			if (get(answer, n) == mx && get2(i + 1, answer - 1) == mx && (n - answer + 1) + i + (answer - 1) - (i + 1) + 1 == n && (answer - 1) - (i + 1) + 1 >= 1 && (n - answer + 1) >= 1)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (answer - 1) - (i + 1) + 1 << " " << (n - answer + 1) << '\n';
				break;
			}
			answer = r;
			if (get(answer, n) == mx && get2(i + 1, answer - 1) == mx && (n - answer + 1) + i + (answer - 1) - (i + 1) + 1 == n && (answer - 1) - (i + 1) + 1 >= 1 && (n - answer + 1) >= 1)
			{
				ok = 1;
				cout << "YES\n";
				cout << i << " " << (answer - 1) - (i + 1) + 1 << " " << (n - answer + 1) << '\n';
				break;
			}
		}
		if (ok)
		{
			continue;
		}
		cout << "NO\n";
    }
}
/*
*/


#pragma GCC optimize ("O3", "unroll-loops")
//#pragma GCC target ("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin())
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CASE(x) int x; cin >> x; while (x--)
#define CASEt(x) int x; cin >> x; for (int tc = 1; tc <= x; ++tc)
using namespace std;
using namespace __gnu_pbds;
namespace {
	const int MOD107 = 1000000007;
	const int MOD998 = 998244353;
	using ll = long long;
	using ull = unsigned long long;
	using pii = pair<int, int>;
	using pll = pair<ll, ll>;
	template <class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
	template <class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
	template <class T> using maxheap = priority_queue<T, vector<T>, less<T>>;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
	struct Modular {
	private:
		long long MODVALUE = 0;
		long long val = 0;

		Modular initModular(long long val) const { return Modular(val, MODVALUE); }

	#ifdef LOCAL
		inline void validate() const {
			assert(MODVALUE != 0);
		}

		inline void validate(const Modular& other) const {
			assert(MODVALUE != 0);
			assert(MODVALUE == other.MODVALUE);
			other.validate();
		}
	#else
		inline void validate() const { }
		inline void validate(const Modular& other) const { }
	#endif

	public:
		explicit operator long long() const { return val; }

		template<class T> Modular& operator = (const T& other) { val = other; return *this; }
		template<class T> void setMod(const T& MOD) { MODVALUE = MOD; }

//		bool operator == (const Modular& other) { validate(other); return val == other.val; }
//		bool operator != (const Modular& other) { return !(*this == other); }
//		template<class T> bool operator == (const T& other) { return *this == initModular(other); }
//		template<class T> bool operator != (const T& other) { return *this != initModular(other); }
//		template<class T> friend bool operator == (const T& other, const Modular& m) { return m.initModular(other) == m; }
//		template<class T> friend bool operator != (const T& other, const Modular& m) { return m.initModular(other) != m; }

//		bool operator <  (const Modular& other) { validate(other); return val <  other.val; }
//		bool operator <= (const Modular& other) { validate(other); return val <= other.val; }
//		bool operator >  (const Modular& other) { validate(other); return val >  other.val; }
//		bool operator >= (const Modular& other) { validate(other); return val >= other.val; }
//		template<class T> bool operator <  (const T& other) { return *this <  initModular(other); }
//		template<class T> bool operator <= (const T& other) { return *this <= initModular(other); }
//		template<class T> bool operator >  (const T& other) { return *this >  initModular(other); }
//		template<class T> bool operator >= (const T& other) { return *this >= initModular(other); }
//		template<class T> friend bool operator <  (const T& other, const Modular& m) { return m.initModular(other) <  m; }
//		template<class T> friend bool operator <= (const T& other, const Modular& m) { return m.initModular(other) <= m; }
//		template<class T> friend bool operator >  (const T& other, const Modular& m) { return m.initModular(other) >  m; }
//		template<class T> friend bool operator >= (const T& other, const Modular& m) { return m.initModular(other) >= m; }

		Modular& operator += (const Modular& other) { validate(other); val += other.val; val %= MODVALUE; return *this; }
		Modular  operator +  (const Modular& other) { Modular tmp = *this; return tmp += other; }
		template<class T> Modular& operator += (const T& other) { return *this += initModular(other); }
		template<class T> Modular  operator +  (const T& other) { return *this +  initModular(other); }
//		template<class T> friend Modular operator += (const T& other, const Modular& m) { return m.initModular(other) += m; }
		template<class T> friend Modular operator +  (const T& other, const Modular& m) { return m.initModular(other) +  m; }

		Modular& operator ++()    { return *this += 1; }
		Modular  operator ++(int) { Modular tmp = *this; ++*this; return tmp; }

		Modular  operator -  () const { return initModular(-val); }
		Modular& operator -= (const Modular& other) { validate(other); val -= other.val; val += MODVALUE; val %= MODVALUE; return *this;}
		Modular  operator -  (const Modular& other) { Modular tmp = *this; return tmp -= other; }
		template<class T> Modular& operator -= (const T& other) { return *this -= initModular(other); }
		template<class T> Modular  operator -  (const T& other) { return *this -  initModular(other); }
//		template<class T> friend Modular operator -= (const T& other, const Modular& m) { return m.initModular(other) -= m; }
		template<class T> friend Modular operator -  (const T& other, const Modular& m) { return m.initModular(other) -  m; }

		Modular& operator --()    { return *this -= 1; }
		Modular  operator --(int) { Modular tmp = *this; --*this; return tmp; }

		Modular& operator *= (const Modular& other) { validate(other); val *= other.val; val %= MODVALUE; val += MODVALUE; val %= MODVALUE; return *this; }
		Modular  operator *  (const Modular& other) { Modular tmp = *this; return tmp *= other; }
		template<class T> Modular& operator *= (const T& other) { return *this *= initModular(other); }
		template<class T> Modular  operator *  (const T& other) { return *this *  initModular(other); }
//		template<class T> friend Modular operator *= (const T& other, const Modular& m) { return m.initModular(other) *= m; }
		template<class T> friend Modular operator *  (const T& other, const Modular& m) { return m.initModular(other) *  m; }

		Modular pow(long long power) const {
			Modular m = *this, ans = initModular(1);
			while (power) {
				if (power & 1) ans *= m;
				m *= m;
				power >>= 1;
			}
			return ans;
		}
		Modular pow(const Modular& other) const { return pow(other.val); }
		Modular inv() const { return pow(MODVALUE-2); }

		Modular& operator /= (const Modular& other) { val *= other.inv().val; val %= MODVALUE; return *this; }
		Modular  operator /  (const Modular& other) { Modular tmp = *this; return tmp /= other; }
		template<class T> Modular& operator /= (const T& other) { return *this /= initModular(other); }
		template<class T> Modular  operator /  (const T& other) { return *this /  initModular(other); }
//		template<class T> friend Modular operator /= (const T& other, const Modular& m) { return m.initModular(other) /= m; }
		template<class T> friend Modular operator /  (const T& other, const Modular& m) { return m.initModular(other) /  m; }

		friend istream& operator >> (istream& in, Modular& m) { in >> m.val; m.val %= m.MODVALUE; m.val += m.MODVALUE; m.val %= m.MODVALUE; return in; }
		friend ostream& operator << (ostream& out, const Modular& m) { return out << m.val; }

		Modular() { val = 0; MODVALUE = 0; }
		Modular(long long val, long long MOD) : MODVALUE(MOD), val((val % MOD + MOD) % MOD) { }
	};
	using Mint = Modular;
	inline ll pow(ll b, ll p, ll mod) {
		b %= mod;
		ll ans = 1;
		for (; p > 0; p >>= 1) {
			if (p&1) {ans *= b; ans %= mod;}
			b *= b;
			b %= mod;
		}
		return ans;
	}
	inline ll max(ll a, int b) { return (a > b ? a : b); }
	inline ll max(int a, ll b) { return (a > b ? a : b); }
	inline ll min(ll a, int b) { return (a < b ? a : b); }
	inline ll min(int a, ll b) { return (a < b ? a : b); }
	template <class T> inline bool chkmin(T&x, const T& y) { return x > y ? x = y, 1 : 0; }
	template <class T> inline bool chkmax(T&x, const T& y) { return x < y ? x = y, 1 : 0; }
}
namespace IO {
	template<class T> inline void _R(T &x) {cin >> x;}
	template<class T1, class T2> inline void _R(pair<T1,T2> &x) {_R(x.first); _R(x.second);}
	template<class T> inline void _R(vector<T> &x) {for (auto& i : x) _R(i);}
	template<class T> inline void _R(deque<T> &x) {for (auto& i : x) _R(i);}
	inline void R() {}
	template<class T1, class... T2> inline void R(T1 &x, T2 &...y) { _R(x); R(y...);}

	template<class T> inline void _W(const T& x);
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p);
	template<class... T> inline void _W(const vector<T...>& x);
	template<class... T> inline void _W(const deque<T...>& x);
	template<class... T> inline void _W(const forward_list<T...>& x);
	template<class... T> inline void _W(const list<T...>& x);
	template<class... T> inline void _W(const set<T...>& x);
	template<class... T> inline void _W(const multiset<T...>& x);
	template<class... T> inline void _W(const unordered_set<T...>& x);
	template<class... T> inline void _W(const unordered_multiset<T...>& x);
	template<class... T> inline void _W(const map<T...>& x);
	template<class... T> inline void _W(const multimap<T...>& x);
	template<class... T> inline void _W(const unordered_map<T...>& x);
	template<class... T> inline void _W(const unordered_multimap<T...>& x);

	template<class T> inline void _W(const ordered_set<T>& x);

	template<class Container> inline void printContainer(const Container& x) { bool isFirst = 1; for (auto i : x) { if (!isFirst) cout << ' '; isFirst = 0; _W(i); } }

	template<class T> inline void _W(const T& x) {cout << x;}
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p) {_W(p.first); _W(' '); _W(p.second);}
	template<class... T> inline void _W(const vector<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const deque<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const forward_list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multimap<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multimap<T...>& x) { printContainer(x); }

	template<class T> inline void _W(const ordered_set<T>& x) { printContainer(x); }

 	inline void W() {cout << '\n';}
	template<class T> inline void W(const T &x) {_W(x); W();}
	template<class T1, class... T2> inline void W(const T1 &x, const T2 &...y) { _W(x); _W(' '); W(y...);}
} using namespace IO;
namespace outputFormat{
	inline string Case(int tc) {return "Case #" + to_string(tc) + ':';}
	inline string YN(bool b) {return b ? "Yes" : "No";}
} using namespace outputFormat;
namespace std {
    template <class T1, class T2> struct hash<pair<T1,T2>> {
    	std::size_t operator()(pair<T1,T2> _) const {
        	return hash<T1>{}(_.first) ^ hash<T2>{}(_.second);
    	}
    };
}
const Mint ZERO = Mint(0, MOD998);

int main() {
	CASE(t) {
		int n; R(n);
		vector<int> a(n); R(a);

		map<int, vector<int>> m;
		for (int i = 0; i < n; i++)
			m[a[i]].pb(i);

		int ml = INT_MAX, mr = INT_MIN;
		bool is = 0;
		for (auto it = m.rbegin(); it != m.rend(); it++) {
			int cnt = it->S.size();
			int lp = it->S.front();
			int rp = it->S.back();

			if (cnt >= 3 && lp < ml && rp > mr) {
				W("YES");
				W(lp + 1, rp - lp - 1, n - rp);
				is = 1;
				break;
			}

			if (is)
				break;

			chkmin(ml, lp);
			chkmax(mr, rp);
		}

		if (!is) {
			W("NO");
		}
	}

	return 0;
}

static auto __init__ = [](){
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	cout << fixed << setprecision(10);
	return 42;
}();


#pragma GCC optimize ("O3", "unroll-loops")
//#pragma GCC target ("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin())
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CASE(x) int x; cin >> x; while (x--)
#define CASEt(x) int x; cin >> x; for (int tc = 1; tc <= x; ++tc)
using namespace std;
using namespace __gnu_pbds;
namespace {
	const int MOD107 = 1000000007;
	const int MOD998 = 998244353;
	using ll = long long;
	using ull = unsigned long long;
	using pii = pair<int, int>;
	using pll = pair<ll, ll>;
	template <class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
	template <class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
	template <class T> using maxheap = priority_queue<T, vector<T>, less<T>>;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
	struct Modular {
	private:
		long long MODVALUE = 0;
		long long val = 0;

		Modular initModular(long long val) const { return Modular(val, MODVALUE); }

	#ifdef LOCAL
		inline void validate() const {
			assert(MODVALUE != 0);
		}

		inline void validate(const Modular& other) const {
			assert(MODVALUE != 0);
			assert(MODVALUE == other.MODVALUE);
			other.validate();
		}
	#else
		inline void validate() const { }
		inline void validate(const Modular& other) const { }
	#endif

	public:
		explicit operator long long() const { return val; }

		template<class T> Modular& operator = (const T& other) { val = other; return *this; }
		template<class T> void setMod(const T& MOD) { MODVALUE = MOD; }

//		bool operator == (const Modular& other) { validate(other); return val == other.val; }
//		bool operator != (const Modular& other) { return !(*this == other); }
//		template<class T> bool operator == (const T& other) { return *this == initModular(other); }
//		template<class T> bool operator != (const T& other) { return *this != initModular(other); }
//		template<class T> friend bool operator == (const T& other, const Modular& m) { return m.initModular(other) == m; }
//		template<class T> friend bool operator != (const T& other, const Modular& m) { return m.initModular(other) != m; }

//		bool operator <  (const Modular& other) { validate(other); return val <  other.val; }
//		bool operator <= (const Modular& other) { validate(other); return val <= other.val; }
//		bool operator >  (const Modular& other) { validate(other); return val >  other.val; }
//		bool operator >= (const Modular& other) { validate(other); return val >= other.val; }
//		template<class T> bool operator <  (const T& other) { return *this <  initModular(other); }
//		template<class T> bool operator <= (const T& other) { return *this <= initModular(other); }
//		template<class T> bool operator >  (const T& other) { return *this >  initModular(other); }
//		template<class T> bool operator >= (const T& other) { return *this >= initModular(other); }
//		template<class T> friend bool operator <  (const T& other, const Modular& m) { return m.initModular(other) <  m; }
//		template<class T> friend bool operator <= (const T& other, const Modular& m) { return m.initModular(other) <= m; }
//		template<class T> friend bool operator >  (const T& other, const Modular& m) { return m.initModular(other) >  m; }
//		template<class T> friend bool operator >= (const T& other, const Modular& m) { return m.initModular(other) >= m; }

		Modular& operator += (const Modular& other) { validate(other); val += other.val; val %= MODVALUE; return *this; }
		Modular  operator +  (const Modular& other) { Modular tmp = *this; return tmp += other; }
		template<class T> Modular& operator += (const T& other) { return *this += initModular(other); }
		template<class T> Modular  operator +  (const T& other) { return *this +  initModular(other); }
//		template<class T> friend Modular operator += (const T& other, const Modular& m) { return m.initModular(other) += m; }
		template<class T> friend Modular operator +  (const T& other, const Modular& m) { return m.initModular(other) +  m; }

		Modular& operator ++()    { return *this += 1; }
		Modular  operator ++(int) { Modular tmp = *this; ++*this; return tmp; }

		Modular  operator -  () const { return initModular(-val); }
		Modular& operator -= (const Modular& other) { validate(other); val -= other.val; val += MODVALUE; val %= MODVALUE; return *this;}
		Modular  operator -  (const Modular& other) { Modular tmp = *this; return tmp -= other; }
		template<class T> Modular& operator -= (const T& other) { return *this -= initModular(other); }
		template<class T> Modular  operator -  (const T& other) { return *this -  initModular(other); }
//		template<class T> friend Modular operator -= (const T& other, const Modular& m) { return m.initModular(other) -= m; }
		template<class T> friend Modular operator -  (const T& other, const Modular& m) { return m.initModular(other) -  m; }

		Modular& operator --()    { return *this -= 1; }
		Modular  operator --(int) { Modular tmp = *this; --*this; return tmp; }

		Modular& operator *= (const Modular& other) { validate(other); val *= other.val; val %= MODVALUE; val += MODVALUE; val %= MODVALUE; return *this; }
		Modular  operator *  (const Modular& other) { Modular tmp = *this; return tmp *= other; }
		template<class T> Modular& operator *= (const T& other) { return *this *= initModular(other); }
		template<class T> Modular  operator *  (const T& other) { return *this *  initModular(other); }
//		template<class T> friend Modular operator *= (const T& other, const Modular& m) { return m.initModular(other) *= m; }
		template<class T> friend Modular operator *  (const T& other, const Modular& m) { return m.initModular(other) *  m; }

		Modular pow(long long power) const {
			Modular m = *this, ans = initModular(1);
			while (power) {
				if (power & 1) ans *= m;
				m *= m;
				power >>= 1;
			}
			return ans;
		}
		Modular pow(const Modular& other) const { return pow(other.val); }
		Modular inv() const { return pow(MODVALUE-2); }

		Modular& operator /= (const Modular& other) { val *= other.inv().val; val %= MODVALUE; return *this; }
		Modular  operator /  (const Modular& other) { Modular tmp = *this; return tmp /= other; }
		template<class T> Modular& operator /= (const T& other) { return *this /= initModular(other); }
		template<class T> Modular  operator /  (const T& other) { return *this /  initModular(other); }
//		template<class T> friend Modular operator /= (const T& other, const Modular& m) { return m.initModular(other) /= m; }
		template<class T> friend Modular operator /  (const T& other, const Modular& m) { return m.initModular(other) /  m; }

		friend istream& operator >> (istream& in, Modular& m) { in >> m.val; m.val %= m.MODVALUE; m.val += m.MODVALUE; m.val %= m.MODVALUE; return in; }
		friend ostream& operator << (ostream& out, const Modular& m) { return out << m.val; }

		Modular() { val = 0; MODVALUE = 0; }
		Modular(long long val, long long MOD) : MODVALUE(MOD), val((val % MOD + MOD) % MOD) { }
	};
	using Mint = Modular;
	inline ll pow(ll b, ll p, ll mod) {
		b %= mod;
		ll ans = 1;
		for (; p > 0; p >>= 1) {
			if (p&1) {ans *= b; ans %= mod;}
			b *= b;
			b %= mod;
		}
		return ans;
	}
	inline ll max(ll a, int b) { return (a > b ? a : b); }
	inline ll max(int a, ll b) { return (a > b ? a : b); }
	inline ll min(ll a, int b) { return (a < b ? a : b); }
	inline ll min(int a, ll b) { return (a < b ? a : b); }
	template <class T> inline bool chkmin(T&x, const T& y) { return x > y ? x = y, 1 : 0; }
	template <class T> inline bool chkmax(T&x, const T& y) { return x < y ? x = y, 1 : 0; }
}
namespace IO {
	template<class T> inline void _R(T &x) {cin >> x;}
	template<class T1, class T2> inline void _R(pair<T1,T2> &x) {_R(x.first); _R(x.second);}
	template<class T> inline void _R(vector<T> &x) {for (auto& i : x) _R(i);}
	template<class T> inline void _R(deque<T> &x) {for (auto& i : x) _R(i);}
	inline void R() {}
	template<class T1, class... T2> inline void R(T1 &x, T2 &...y) { _R(x); R(y...);}

	template<class T> inline void _W(const T& x);
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p);
	template<class... T> inline void _W(const vector<T...>& x);
	template<class... T> inline void _W(const deque<T...>& x);
	template<class... T> inline void _W(const forward_list<T...>& x);
	template<class... T> inline void _W(const list<T...>& x);
	template<class... T> inline void _W(const set<T...>& x);
	template<class... T> inline void _W(const multiset<T...>& x);
	template<class... T> inline void _W(const unordered_set<T...>& x);
	template<class... T> inline void _W(const unordered_multiset<T...>& x);
	template<class... T> inline void _W(const map<T...>& x);
	template<class... T> inline void _W(const multimap<T...>& x);
	template<class... T> inline void _W(const unordered_map<T...>& x);
	template<class... T> inline void _W(const unordered_multimap<T...>& x);

	template<class T> inline void _W(const ordered_set<T>& x);

	template<class Container> inline void printContainer(const Container& x) { bool isFirst = 1; for (auto i : x) { if (!isFirst) cout << ' '; isFirst = 0; _W(i); } }

	template<class T> inline void _W(const T& x) {cout << x;}
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p) {_W(p.first); _W(' '); _W(p.second);}
	template<class... T> inline void _W(const vector<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const deque<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const forward_list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multimap<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multimap<T...>& x) { printContainer(x); }

	template<class T> inline void _W(const ordered_set<T>& x) { printContainer(x); }

 	inline void W() {cout << '\n';}
	template<class T> inline void W(const T &x) {_W(x); W();}
	template<class T1, class... T2> inline void W(const T1 &x, const T2 &...y) { _W(x); _W(' '); W(y...);}
} using namespace IO;
namespace outputFormat{
	inline string Case(int tc) {return "Case #" + to_string(tc) + ':';}
	inline string YN(bool b) {return b ? "Yes" : "No";}
} using namespace outputFormat;
namespace std {
    template <class T1, class T2> struct hash<pair<T1,T2>> {
    	std::size_t operator()(pair<T1,T2> _) const {
        	return hash<T1>{}(_.first) ^ hash<T2>{}(_.second);
    	}
    };
}
const Mint ZERO = Mint(0, MOD998);

int main() {
	CASE(t) {
		int n; R(n);
		vector<int> a(n); R(a);

		map<int, vector<int>> m;
		for (int i = 0; i < n; i++)
			m[a[i]].pb(i);

		int ml = INT_MAX, mr = INT_MIN;
		bool is = 0;
		for (auto it = m.rbegin(); it != m.rend(); it++) {
			int cnt = it->S.size();
			int lp = it->S.front();
			int rp = it->S.back();

			if (cnt >= 3 && lp < ml && rp > mr) {
				W("YES");
				chkmin(ml, it->S[1]);
				chkmax(mr, it->S[1]);
				W(ml, mr - ml + 1, n - mr - 1);
				is = 1;
				break;
			}

			if (is)
				break;

			chkmin(ml, lp);
			chkmax(mr, rp);
		}

		if (!is) {
			W("NO");
		}
	}

	return 0;
}

static auto __init__ = [](){
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	cout << fixed << setprecision(10);
	return 42;
}();


#pragma GCC optimize ("O3", "unroll-loops")
//#pragma GCC target ("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin())
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CASE(x) int x; cin >> x; while (x--)
#define CASEt(x) int x; cin >> x; for (int tc = 1; tc <= x; ++tc)
using namespace std;
using namespace __gnu_pbds;
namespace {
	const int MOD107 = 1000000007;
	const int MOD998 = 998244353;
	using ll = long long;
	using ull = unsigned long long;
	using pii = pair<int, int>;
	using pll = pair<ll, ll>;
	template <class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
	template <class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
	template <class T> using maxheap = priority_queue<T, vector<T>, less<T>>;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
	struct Modular {
	private:
		long long MODVALUE = 0;
		long long val = 0;

		Modular initModular(long long val) const { return Modular(val, MODVALUE); }

	#ifdef LOCAL
		inline void validate() const {
			assert(MODVALUE != 0);
		}

		inline void validate(const Modular& other) const {
			assert(MODVALUE != 0);
			assert(MODVALUE == other.MODVALUE);
			other.validate();
		}
	#else
		inline void validate() const { }
		inline void validate(const Modular& other) const { }
	#endif

	public:
		explicit operator long long() const { return val; }

		template<class T> Modular& operator = (const T& other) { val = other; return *this; }
		template<class T> void setMod(const T& MOD) { MODVALUE = MOD; }

//		bool operator == (const Modular& other) { validate(other); return val == other.val; }
//		bool operator != (const Modular& other) { return !(*this == other); }
//		template<class T> bool operator == (const T& other) { return *this == initModular(other); }
//		template<class T> bool operator != (const T& other) { return *this != initModular(other); }
//		template<class T> friend bool operator == (const T& other, const Modular& m) { return m.initModular(other) == m; }
//		template<class T> friend bool operator != (const T& other, const Modular& m) { return m.initModular(other) != m; }

//		bool operator <  (const Modular& other) { validate(other); return val <  other.val; }
//		bool operator <= (const Modular& other) { validate(other); return val <= other.val; }
//		bool operator >  (const Modular& other) { validate(other); return val >  other.val; }
//		bool operator >= (const Modular& other) { validate(other); return val >= other.val; }
//		template<class T> bool operator <  (const T& other) { return *this <  initModular(other); }
//		template<class T> bool operator <= (const T& other) { return *this <= initModular(other); }
//		template<class T> bool operator >  (const T& other) { return *this >  initModular(other); }
//		template<class T> bool operator >= (const T& other) { return *this >= initModular(other); }
//		template<class T> friend bool operator <  (const T& other, const Modular& m) { return m.initModular(other) <  m; }
//		template<class T> friend bool operator <= (const T& other, const Modular& m) { return m.initModular(other) <= m; }
//		template<class T> friend bool operator >  (const T& other, const Modular& m) { return m.initModular(other) >  m; }
//		template<class T> friend bool operator >= (const T& other, const Modular& m) { return m.initModular(other) >= m; }

		Modular& operator += (const Modular& other) { validate(other); val += other.val; val %= MODVALUE; return *this; }
		Modular  operator +  (const Modular& other) { Modular tmp = *this; return tmp += other; }
		template<class T> Modular& operator += (const T& other) { return *this += initModular(other); }
		template<class T> Modular  operator +  (const T& other) { return *this +  initModular(other); }
//		template<class T> friend Modular operator += (const T& other, const Modular& m) { return m.initModular(other) += m; }
		template<class T> friend Modular operator +  (const T& other, const Modular& m) { return m.initModular(other) +  m; }

		Modular& operator ++()    { return *this += 1; }
		Modular  operator ++(int) { Modular tmp = *this; ++*this; return tmp; }

		Modular  operator -  () const { return initModular(-val); }
		Modular& operator -= (const Modular& other) { validate(other); val -= other.val; val += MODVALUE; val %= MODVALUE; return *this;}
		Modular  operator -  (const Modular& other) { Modular tmp = *this; return tmp -= other; }
		template<class T> Modular& operator -= (const T& other) { return *this -= initModular(other); }
		template<class T> Modular  operator -  (const T& other) { return *this -  initModular(other); }
//		template<class T> friend Modular operator -= (const T& other, const Modular& m) { return m.initModular(other) -= m; }
		template<class T> friend Modular operator -  (const T& other, const Modular& m) { return m.initModular(other) -  m; }

		Modular& operator --()    { return *this -= 1; }
		Modular  operator --(int) { Modular tmp = *this; --*this; return tmp; }

		Modular& operator *= (const Modular& other) { validate(other); val *= other.val; val %= MODVALUE; val += MODVALUE; val %= MODVALUE; return *this; }
		Modular  operator *  (const Modular& other) { Modular tmp = *this; return tmp *= other; }
		template<class T> Modular& operator *= (const T& other) { return *this *= initModular(other); }
		template<class T> Modular  operator *  (const T& other) { return *this *  initModular(other); }
//		template<class T> friend Modular operator *= (const T& other, const Modular& m) { return m.initModular(other) *= m; }
		template<class T> friend Modular operator *  (const T& other, const Modular& m) { return m.initModular(other) *  m; }

		Modular pow(long long power) const {
			Modular m = *this, ans = initModular(1);
			while (power) {
				if (power & 1) ans *= m;
				m *= m;
				power >>= 1;
			}
			return ans;
		}
		Modular pow(const Modular& other) const { return pow(other.val); }
		Modular inv() const { return pow(MODVALUE-2); }

		Modular& operator /= (const Modular& other) { val *= other.inv().val; val %= MODVALUE; return *this; }
		Modular  operator /  (const Modular& other) { Modular tmp = *this; return tmp /= other; }
		template<class T> Modular& operator /= (const T& other) { return *this /= initModular(other); }
		template<class T> Modular  operator /  (const T& other) { return *this /  initModular(other); }
//		template<class T> friend Modular operator /= (const T& other, const Modular& m) { return m.initModular(other) /= m; }
		template<class T> friend Modular operator /  (const T& other, const Modular& m) { return m.initModular(other) /  m; }

		friend istream& operator >> (istream& in, Modular& m) { in >> m.val; m.val %= m.MODVALUE; m.val += m.MODVALUE; m.val %= m.MODVALUE; return in; }
		friend ostream& operator << (ostream& out, const Modular& m) { return out << m.val; }

		Modular() { val = 0; MODVALUE = 0; }
		Modular(long long val, long long MOD) : MODVALUE(MOD), val((val % MOD + MOD) % MOD) { }
	};
	using Mint = Modular;
	inline ll pow(ll b, ll p, ll mod) {
		b %= mod;
		ll ans = 1;
		for (; p > 0; p >>= 1) {
			if (p&1) {ans *= b; ans %= mod;}
			b *= b;
			b %= mod;
		}
		return ans;
	}
	inline ll max(ll a, int b) { return (a > b ? a : b); }
	inline ll max(int a, ll b) { return (a > b ? a : b); }
	inline ll min(ll a, int b) { return (a < b ? a : b); }
	inline ll min(int a, ll b) { return (a < b ? a : b); }
	template <class T> inline bool chkmin(T&x, const T& y) { return x > y ? x = y, 1 : 0; }
	template <class T> inline bool chkmax(T&x, const T& y) { return x < y ? x = y, 1 : 0; }
}
namespace IO {
	template<class T> inline void _R(T &x) {cin >> x;}
	template<class T1, class T2> inline void _R(pair<T1,T2> &x) {_R(x.first); _R(x.second);}
	template<class T> inline void _R(vector<T> &x) {for (auto& i : x) _R(i);}
	template<class T> inline void _R(deque<T> &x) {for (auto& i : x) _R(i);}
	inline void R() {}
	template<class T1, class... T2> inline void R(T1 &x, T2 &...y) { _R(x); R(y...);}

	template<class T> inline void _W(const T& x);
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p);
	template<class... T> inline void _W(const vector<T...>& x);
	template<class... T> inline void _W(const deque<T...>& x);
	template<class... T> inline void _W(const forward_list<T...>& x);
	template<class... T> inline void _W(const list<T...>& x);
	template<class... T> inline void _W(const set<T...>& x);
	template<class... T> inline void _W(const multiset<T...>& x);
	template<class... T> inline void _W(const unordered_set<T...>& x);
	template<class... T> inline void _W(const unordered_multiset<T...>& x);
	template<class... T> inline void _W(const map<T...>& x);
	template<class... T> inline void _W(const multimap<T...>& x);
	template<class... T> inline void _W(const unordered_map<T...>& x);
	template<class... T> inline void _W(const unordered_multimap<T...>& x);

	template<class T> inline void _W(const ordered_set<T>& x);

	template<class Container> inline void printContainer(const Container& x) { bool isFirst = 1; for (auto i : x) { if (!isFirst) cout << ' '; isFirst = 0; _W(i); } }

	template<class T> inline void _W(const T& x) {cout << x;}
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p) {_W(p.first); _W(' '); _W(p.second);}
	template<class... T> inline void _W(const vector<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const deque<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const forward_list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multimap<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multimap<T...>& x) { printContainer(x); }

	template<class T> inline void _W(const ordered_set<T>& x) { printContainer(x); }

 	inline void W() {cout << '\n';}
	template<class T> inline void W(const T &x) {_W(x); W();}
	template<class T1, class... T2> inline void W(const T1 &x, const T2 &...y) { _W(x); _W(' '); W(y...);}
} using namespace IO;
namespace outputFormat{
	inline string Case(int tc) {return "Case #" + to_string(tc) + ':';}
	inline string YN(bool b) {return b ? "Yes" : "No";}
} using namespace outputFormat;
namespace std {
    template <class T1, class T2> struct hash<pair<T1,T2>> {
    	std::size_t operator()(pair<T1,T2> _) const {
        	return hash<T1>{}(_.first) ^ hash<T2>{}(_.second);
    	}
    };
}
const Mint ZERO = Mint(0, MOD998);

template<class T>
struct SparseTable {
private:
	vector<vector<T>> sparseTable = vector<vector<T>>(1);
	function<T(T,T)> func;

public:
	vector<T>& operator [] (int level) {return sparseTable[level];}
	int size() {return sparseTable.size();}
	T query(int l, int r) {
		assert(l <= r);
		int level = __lg(r - l + 1);
		return func(sparseTable[level][l], sparseTable[level][r - (1 << level) + 1]);
	}
	void build() {
		int baseSize = sparseTable[0].size();
		for (int i = 1; ; i++) {
			int curSize = baseSize - (1 << i) + 1;
			if (curSize > 0) {
				if (sparseTable.size() >= i + 1)
					sparseTable[i].clear();
				else
					sparseTable.push_back(vector<T>());
				sparseTable[i].resize(curSize);
				for (int j = 0; j < curSize; j++)
					sparseTable[i][j] = func(sparseTable[i-1][j], sparseTable[i-1][j + (1 << i - 1)]);
			} else break;
		}
	}
	SparseTable(vector<T>& v, function<T(T,T)> func) : func(func) {sparseTable[0] = v; build();}
	SparseTable(int size, function<T(T,T)> func) : func(func) {sparseTable[0].resize(size);}
};

int main() {
	CASE(t) {
		int n; R(n);
		vector<int> a(n); R(a);

		map<int, int> last;
		for (int i = 0; i < n; i++)
			last[a[i]] = i;

		SparseTable<int> minST(a, [&](int x, int y) {
			return min(x, y);
		}), maxST(a, [&](int x, int y) {
			return max(x, y);
		});

		int pmax = INT_MIN;
		bool is = 0;
		for (int i = 0; i < n - 2; i++) {
			chkmax(pmax, a[i]);

			int l = i + 1, r = n - 1;
			while (r > l) {
				int mid = l + r + 1 >> 1;
				int v = minST.query(i + 1, mid);

				if (v >= pmax) {
					l = mid;
				} else {
					r = mid - 1;
				}
			}
			int mr = min(l, last[pmax] - 1);
			if (mr <= i)
				continue;

			int x = maxST.query(0, i);
			int y = minST.query(i + 1, mr);
			int z = maxST.query(mr + 1, n - 1);
			if (x == y && y == z) {
				W("YES");
				W(i + 1, mr - i, n - mr - 1);
				is = 1;
				break;
			}
		}

		if (!is) {
			W("NO");
		}
	}

	return 0;
}

static auto __init__ = [](){
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	cout << fixed << setprecision(10);
	return 42;
}();


#pragma GCC optimize ("O3", "unroll-loops")
//#pragma GCC target ("avx2")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin())
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CASE(x) int x; cin >> x; while (x--)
#define CASEt(x) int x; cin >> x; for (int tc = 1; tc <= x; ++tc)
using namespace std;
using namespace __gnu_pbds;
namespace {
	const int MOD107 = 1000000007;
	const int MOD998 = 998244353;
	using ll = long long;
	using ull = unsigned long long;
	using pii = pair<int, int>;
	using pll = pair<ll, ll>;
	template <class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
	template <class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
	template <class T> using maxheap = priority_queue<T, vector<T>, less<T>>;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
	struct Modular {
	private:
		long long MODVALUE = 0;
		long long val = 0;

		Modular initModular(long long val) const { return Modular(val, MODVALUE); }

	#ifdef LOCAL
		inline void validate() const {
			assert(MODVALUE != 0);
		}

		inline void validate(const Modular& other) const {
			assert(MODVALUE != 0);
			assert(MODVALUE == other.MODVALUE);
			other.validate();
		}
	#else
		inline void validate() const { }
		inline void validate(const Modular& other) const { }
	#endif

	public:
		explicit operator long long() const { return val; }

		template<class T> Modular& operator = (const T& other) { val = other; return *this; }
		template<class T> void setMod(const T& MOD) { MODVALUE = MOD; }

//		bool operator == (const Modular& other) { validate(other); return val == other.val; }
//		bool operator != (const Modular& other) { return !(*this == other); }
//		template<class T> bool operator == (const T& other) { return *this == initModular(other); }
//		template<class T> bool operator != (const T& other) { return *this != initModular(other); }
//		template<class T> friend bool operator == (const T& other, const Modular& m) { return m.initModular(other) == m; }
//		template<class T> friend bool operator != (const T& other, const Modular& m) { return m.initModular(other) != m; }

//		bool operator <  (const Modular& other) { validate(other); return val <  other.val; }
//		bool operator <= (const Modular& other) { validate(other); return val <= other.val; }
//		bool operator >  (const Modular& other) { validate(other); return val >  other.val; }
//		bool operator >= (const Modular& other) { validate(other); return val >= other.val; }
//		template<class T> bool operator <  (const T& other) { return *this <  initModular(other); }
//		template<class T> bool operator <= (const T& other) { return *this <= initModular(other); }
//		template<class T> bool operator >  (const T& other) { return *this >  initModular(other); }
//		template<class T> bool operator >= (const T& other) { return *this >= initModular(other); }
//		template<class T> friend bool operator <  (const T& other, const Modular& m) { return m.initModular(other) <  m; }
//		template<class T> friend bool operator <= (const T& other, const Modular& m) { return m.initModular(other) <= m; }
//		template<class T> friend bool operator >  (const T& other, const Modular& m) { return m.initModular(other) >  m; }
//		template<class T> friend bool operator >= (const T& other, const Modular& m) { return m.initModular(other) >= m; }

		Modular& operator += (const Modular& other) { validate(other); val += other.val; val %= MODVALUE; return *this; }
		Modular  operator +  (const Modular& other) { Modular tmp = *this; return tmp += other; }
		template<class T> Modular& operator += (const T& other) { return *this += initModular(other); }
		template<class T> Modular  operator +  (const T& other) { return *this +  initModular(other); }
//		template<class T> friend Modular operator += (const T& other, const Modular& m) { return m.initModular(other) += m; }
		template<class T> friend Modular operator +  (const T& other, const Modular& m) { return m.initModular(other) +  m; }

		Modular& operator ++()    { return *this += 1; }
		Modular  operator ++(int) { Modular tmp = *this; ++*this; return tmp; }

		Modular  operator -  () const { return initModular(-val); }
		Modular& operator -= (const Modular& other) { validate(other); val -= other.val; val += MODVALUE; val %= MODVALUE; return *this;}
		Modular  operator -  (const Modular& other) { Modular tmp = *this; return tmp -= other; }
		template<class T> Modular& operator -= (const T& other) { return *this -= initModular(other); }
		template<class T> Modular  operator -  (const T& other) { return *this -  initModular(other); }
//		template<class T> friend Modular operator -= (const T& other, const Modular& m) { return m.initModular(other) -= m; }
		template<class T> friend Modular operator -  (const T& other, const Modular& m) { return m.initModular(other) -  m; }

		Modular& operator --()    { return *this -= 1; }
		Modular  operator --(int) { Modular tmp = *this; --*this; return tmp; }

		Modular& operator *= (const Modular& other) { validate(other); val *= other.val; val %= MODVALUE; val += MODVALUE; val %= MODVALUE; return *this; }
		Modular  operator *  (const Modular& other) { Modular tmp = *this; return tmp *= other; }
		template<class T> Modular& operator *= (const T& other) { return *this *= initModular(other); }
		template<class T> Modular  operator *  (const T& other) { return *this *  initModular(other); }
//		template<class T> friend Modular operator *= (const T& other, const Modular& m) { return m.initModular(other) *= m; }
		template<class T> friend Modular operator *  (const T& other, const Modular& m) { return m.initModular(other) *  m; }

		Modular pow(long long power) const {
			Modular m = *this, ans = initModular(1);
			while (power) {
				if (power & 1) ans *= m;
				m *= m;
				power >>= 1;
			}
			return ans;
		}
		Modular pow(const Modular& other) const { return pow(other.val); }
		Modular inv() const { return pow(MODVALUE-2); }

		Modular& operator /= (const Modular& other) { val *= other.inv().val; val %= MODVALUE; return *this; }
		Modular  operator /  (const Modular& other) { Modular tmp = *this; return tmp /= other; }
		template<class T> Modular& operator /= (const T& other) { return *this /= initModular(other); }
		template<class T> Modular  operator /  (const T& other) { return *this /  initModular(other); }
//		template<class T> friend Modular operator /= (const T& other, const Modular& m) { return m.initModular(other) /= m; }
		template<class T> friend Modular operator /  (const T& other, const Modular& m) { return m.initModular(other) /  m; }

		friend istream& operator >> (istream& in, Modular& m) { in >> m.val; m.val %= m.MODVALUE; m.val += m.MODVALUE; m.val %= m.MODVALUE; return in; }
		friend ostream& operator << (ostream& out, const Modular& m) { return out << m.val; }

		Modular() { val = 0; MODVALUE = 0; }
		Modular(long long val, long long MOD) : MODVALUE(MOD), val((val % MOD + MOD) % MOD) { }
	};
	using Mint = Modular;
	inline ll pow(ll b, ll p, ll mod) {
		b %= mod;
		ll ans = 1;
		for (; p > 0; p >>= 1) {
			if (p&1) {ans *= b; ans %= mod;}
			b *= b;
			b %= mod;
		}
		return ans;
	}
	inline ll max(ll a, int b) { return (a > b ? a : b); }
	inline ll max(int a, ll b) { return (a > b ? a : b); }
	inline ll min(ll a, int b) { return (a < b ? a : b); }
	inline ll min(int a, ll b) { return (a < b ? a : b); }
	template <class T> inline bool chkmin(T&x, const T& y) { return x > y ? x = y, 1 : 0; }
	template <class T> inline bool chkmax(T&x, const T& y) { return x < y ? x = y, 1 : 0; }
}
namespace IO {
	template<class T> inline void _R(T &x) {cin >> x;}
	template<class T1, class T2> inline void _R(pair<T1,T2> &x) {_R(x.first); _R(x.second);}
	template<class T> inline void _R(vector<T> &x) {for (auto& i : x) _R(i);}
	template<class T> inline void _R(deque<T> &x) {for (auto& i : x) _R(i);}
	inline void R() {}
	template<class T1, class... T2> inline void R(T1 &x, T2 &...y) { _R(x); R(y...);}

	template<class T> inline void _W(const T& x);
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p);
	template<class... T> inline void _W(const vector<T...>& x);
	template<class... T> inline void _W(const deque<T...>& x);
	template<class... T> inline void _W(const forward_list<T...>& x);
	template<class... T> inline void _W(const list<T...>& x);
	template<class... T> inline void _W(const set<T...>& x);
	template<class... T> inline void _W(const multiset<T...>& x);
	template<class... T> inline void _W(const unordered_set<T...>& x);
	template<class... T> inline void _W(const unordered_multiset<T...>& x);
	template<class... T> inline void _W(const map<T...>& x);
	template<class... T> inline void _W(const multimap<T...>& x);
	template<class... T> inline void _W(const unordered_map<T...>& x);
	template<class... T> inline void _W(const unordered_multimap<T...>& x);

	template<class T> inline void _W(const ordered_set<T>& x);

	template<class Container> inline void printContainer(const Container& x) { bool isFirst = 1; for (auto i : x) { if (!isFirst) cout << ' '; isFirst = 0; _W(i); } }

	template<class T> inline void _W(const T& x) {cout << x;}
	template<class T1, class T2> inline void _W(const pair<T1,T2>& p) {_W(p.first); _W(' '); _W(p.second);}
	template<class... T> inline void _W(const vector<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const deque<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const forward_list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const list<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_set<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multiset<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const multimap<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_map<T...>& x) { printContainer(x); }
	template<class... T> inline void _W(const unordered_multimap<T...>& x) { printContainer(x); }

	template<class T> inline void _W(const ordered_set<T>& x) { printContainer(x); }

 	inline void W() {cout << '\n';}
	template<class T> inline void W(const T &x) {_W(x); W();}
	template<class T1, class... T2> inline void W(const T1 &x, const T2 &...y) { _W(x); _W(' '); W(y...);}
} using namespace IO;
namespace outputFormat{
	inline string Case(int tc) {return "Case #" + to_string(tc) + ':';}
	inline string YN(bool b) {return b ? "Yes" : "No";}
} using namespace outputFormat;
namespace std {
    template <class T1, class T2> struct hash<pair<T1,T2>> {
    	std::size_t operator()(pair<T1,T2> _) const {
        	return hash<T1>{}(_.first) ^ hash<T2>{}(_.second);
    	}
    };
}
const Mint ZERO = Mint(0, MOD998);

int main() {
	CASE(t) {
		int n; R(n);
		vector<int> a(n); R(a);

		map<int, vector<int>> m;
		for (int i = 0; i < n; i++)
			m[a[i]].pb(i);

		int ml = m.rbegin()->S[1], mr = ml;
		int minv = m.rbegin()->F;
		bool is = 0;
		for (auto it = m.rbegin(); it != m.rend(); it++) {
			int cnt = it->S.size();
			int lp = it->S.front();
			int rp = it->S.back();

			if (it->F <= minv && cnt >= 3 && lp < ml && rp > mr) {
				W("YES");
				chkmin(ml, it->S[1]);
				chkmax(mr, it->S[1]);
				W(ml, mr - ml + 1, n - mr - 1);
				is = 1;
				break;
			}

			if (is)
				break;

			while (ml > lp)
				chkmin(minv, a[--ml]);
			while (mr < rp)
				chkmin(minv, a[++mr]);
		}

		if (!is) {
			W("NO");
		}
	}

	return 0;
}

static auto __init__ = [](){
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	cout << fixed << setprecision(10);
	return 42;
}();


#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
*/