//Game

#include<bits/stdc++.h>

#define int long long 
#define sq(a) (a*a)
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod (int)(1e9+7)
#define endl "\n"
#define N (int)(1000001)
#define inf (int)(1e18)
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main()
{
    int t;cin>>t;
    while(t--)
    {
        int n; cin>>n;
        map<int,vector<int>> m;
        map<int,int> f;
        vector<int> v(n);
        for(int i=0;i<n;i++)
        {
            cin>>v[i];
            m[v[i]].pb(i);
            f[v[i]]++;
        }
        int r = inf;
        for(auto x:m)
        {
            int k=0,p=inf;
            for(auto y:x.ss)
            {
                 
                {
                    if(y!=p+1 and y)k++;
                    p = y;
                }
            }
            if(p!=n-1)k++;
            r=min(r,k);
        }
        cout<<r<<endl;
    }
    return 0;
}
