#include "bits/stdc++.h"
using namespace std;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define fob(i, b, a) for(int i = b; i>=a; i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define int long long
#define all(v) (v).begin(),(v).end() 
#define arl(v) (v).rbegin(),(v).rend() // from right
#define vmn(a) (*min_element(a.begin(),a.end())) // vector min   
#define vmx(a) (*max_element(a.begin(),a.end())) // vector max
#define len(a) ((int)a.size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arrin(arr) for(auto &i: arr) cin>>i;
#define print(a) for(auto i: a) cout<<i<<" "; cout<<endl;
    
void code(){
    int n; cin>>n;
    map<int, vector<int>> mp;
    fo(i, 0, n) {
        int a; cin>>a;
        mp[a].pb(i);
    }
    
    int ans = INT_MAX;
    for(auto i: mp) {
        int cnt = 0;
        int len = len(i.S);
        if(i.S[0]>0) cnt++;
        if(i.S[len-1]<n-1) cnt++;
        fo(j, 0, len-1)
            if(i.S[j+1]-i.S[j]>1) cnt++;
        
        ans = min(ans, cnt);
    }
    cout<<ans<<endl;

}
    
signed main(){
    IOS;
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    cin>>t;
    fo(i, 0, t) {
        //cout<<"Case #"<<i+1<<": ";
        code();
    }
    return 0;
}