func_code_string: #include <bits/stdc++.h>   //#include <bits/extc++.h>   #define ll long long   #define endl   n    #define pb push_back   #define ms(v,x) memset(v,x,sizeof(v))   #define ff first   #define ss second   #define td(v) v.begin(),v.end()   #define rep(i,a,n) for (int i=(a);i<(n);i++)   #define per(i,a,n) for (int i=(n-1);i>=a;i--)   #define trav(a, x) for(auto& a : x)   #define re(v) {for(auto &_re : v) cin >> _re;}   #define pr(v) {for(auto _pr : v) cout << _pr <<    ; cout << endl;}   #define sz(x) (int)(x).size()   #define all(x) x.begin(), x.end()   #define pii pair<int,int>   #define pll pair<ll,ll>   #define vi vector<int>   #define vl vector<ll>   #define eb emplace_back   using namespace std;   using vvi = vector<vi>;   using vvl = vector<vl>;   const ll M = 1e9 + 7;   //const ll M = 998244353;   //const ll M = 1e6;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   ll binpow(ll a, ll b){    ll res = (a!=0);    while(b > 0){     if(b&1) res = res * a % M;     a = a * a % M;     b>>=1;    }    return res;   }   //#define double long double   //#define int long long   //#define tiii tuple<int,int,int>   //#define uint unsigned int   void solve(){    int n;    cin >> n;    vi a(n), c(n + 1);     re(a);    for(int i=0;i<n;i++){     int j = i;     while(j+1 < n && a[j + 1] == a[i]){      j++;     }     c[a[i]]++;     i = j;    }    int ans = n + 1;    for(int i=0;i<n;i++){     ans = min(ans, c[a[i]] + 1 - (a[i] == a[0]) - (a[i] == a.back()));    }    cout << ans << endl;   }   int32_t main(){     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);     //freopen( .in ,  r , stdin);    //freopen( .out ,  w , stdout);    int t = 1;    cin >> t;    while(t--){     solve();    }   }