#include<bits/stdc++.h>
#define endl '\n'
#define pairs pair<int,int>
#define loop(i,n) for(int i = 0;i < int(n);++i)
#define rloop(i,n) for(int i = int(n-1);i>=0;--i)
#define range(i,a,b) for(int i = int(a);i <=int(b);i++)
#define ll long long
using namespace std;
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		int n; cin >> n;
		map<int, vector<int>>mp;
		loop(i, n) {
			int m;
			cin >> m;
			mp[m].push_back(i);
		}
		int res = 1e9;
		for (auto& x : mp) {
			int cnt = 0;
			loop(i, x.second.size()) {
				if (i == 0) {
					if (x.second[i] != 0)cnt++;
				}
				if (i == x.second.size() - 1) {
					if (x.second[i] != n-1)cnt++;
				}
				if (i && x.second[i] != x.second[i - 1] + 1) {
					cnt++;
				}
			}
			res = min(cnt, res);
		}
		cout << res << endl;

	}
}