//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll t;
    cin>>t;
    while(t--)
    {
        ll n,i,j,k;
        cin>>n;
        vector<ll> a(n),c(n+1);
        rep(i,0,n-1)
        {
            cin>>a[i];
            c[a[i]]++;
        }
        vector<ll> pos[n+1];
        rep(i,0,n)pos[i].pb(-1);
        rep(i,0,n-1)pos[a[i]].pb(i);
        rep(i,0,n)pos[i].pb(n);
        ll ans=inf;
        rep(i,1,n)
        {
            ll g=0;
            if(pos[i].size()==2)
                continue;
            rep(j,0,pos[i].size()-2)
            {
                if(pos[i][j+1]-pos[i][j]>1)
                    g++;
            }
            ans=min(ans,g);
        }cout<<ans<<en;
    }
    return 0;
}
