#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
const double eps=1e-6;
const int N=2e5+5,M=1e9+7,OO=0x3f3f3f3f;
int t,n,m,k;

int arr[N];



int main(){
    //freopen("icecream.in","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("myfile.txt","w",stdout);

    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        vector<vector<int> > oc;
        oc.resize(n+1);
        for(int i=0;i<n;++i)
            scanf("%d",arr+i),oc[arr[i]].push_back(i);
        for(int i=1;i<=n;++i)
            oc[i].push_back(n);
        int ans=OO;
        for(int i=1;i<=n;++i){
            if(oc[i].size()==1) continue;
            int cur=0,prv=-1;
            for(int j=0;j<oc[i].size();++j){
                if(oc[i][j]-prv>1) ++cur;
                prv=oc[i][j];
            }
            ans=min(ans,cur);
        }
        printf("%d\n",ans);
    }

    return 0;
}
