#include <bits/stdc++.h>

#define INF 1e9
#define LL long long
#define MP make_pair
#define PB push_back

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int T, result, N, val;

	cin >> T;
	while(T--) {
		result = INF;
		cin >> N;

		vector<int> arr[N+2];

		for(int i = 1; i <= N; i++) {
			cin >> val;

			arr[val].PB(i);
		}
		
		// for(int i = 1; i <= N; i++) {
		// 	cout << i << ": ";
		// 	for(int j = 0; j < arr[i].size(); j++) {
		// 		cout << arr[i][j] << ", ";
		// 	}
		// 	cout << endl;
		// }

		for(int i = 1; i <= N; i++) {
			int lastIndex = 0;
			int sumSliced = 0;
			for(int j = 0; j < arr[i].size(); j++) {
				if(arr[i][j]-lastIndex > 1) {
					sumSliced++;
				}
				lastIndex = arr[i][j];
			}
			if(arr[i].size() > 0) {
				if((N+1 - lastIndex > 1)) {
					sumSliced++;
				}
				if(sumSliced < result) {
					result = sumSliced;
				}
			}
		}

		cout << result << endl;
	}
	
	return 0;
}