#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define endl "\n"
#define mod 1000000007
using namespace std;

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		ll a[n];
		map<ll, vector<int> >m;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			m[a[i]].push_back(i+1);
		}	
		int ans=INT_MAX;
		for(auto x:m)
		{
			vector<int>v=x.second;
			int size=v.size();
			int start=0;
			int count=0;
			for(int i=0;i<size;i++){
				if(v[i]-start>1)
				count++;
				start=v[i];
			}
			if(n+1-start>1)
			count++;
//			cout<<start<<endl;
			ans=min(ans,count);
		}
		cout<<ans<<endl;
//		cout<<ans<<endl;
	}
}
