/*All praise be to Allah*/
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef unsigned int long long uill;
typedef int long long ill;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/* ///// ** code ** ///// */




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,n,x,ans=inf;
    cin>>t;

    while(t--)
    {
        ans=inf;
        vector<pair<int,int> >v;
        cin>>n;
        for(int i=0; i<n; i++)
        {
            cin>>x;
            v.push_back({x,i});
        }
        sort(v.begin(),v.end());

//        for(auto a:v)
//        {
//            cout<<a.first<<"    "<<a.second<<"\n";
//        }


        for(int i=0; i<n; i++)
        {
            x=0;
            if(v[i].second!=0)x++;
            while(i<n-1&&v[i].first==v[i+1].first)
            {
                if(v[i].second+1!=(v[i+1].second))x++;
                i++;
            }

            if(v[i].second!=n-1)x++;
            ans=min(ans,x);
        }
cout<<ans<<"\n";

    }




    return 0;
}
