// بسم الله الرحمن الرحيم
//______________________________________________________________________________________________________________________
// ooooooooooooo oooo .o8 .o8
// 8' 888 `8 `888 "888 "888
// 888 .oooo. 888 .oo. 888oooo. .ooooo. oooo oooo 888oooo.
// 888 `P )88b 888P"Y88b d88' `88b d88' `88b `888 `888 d88' `88b
// 888 .oP"888 888 888 888 888 888 888 888 888 888 888
// 888 d8( 888 888 888 888 888 888 888 888 888 888 888
// o888o `Y888""8o o888o o888o `Y8bod8P' `Y8bod8P' `V88V"V8P' `Y8bod8P'
//______________________________________________________________________________________________________________________
// #
// #@@
// @@@
// @@
// @@
// @# @ @@@& @@
// @ @@ @@@@@ @@@ @* @@ @@ /@@@@@@@@@
// %@ @& @@ @@ @@* ,@ @# @@@( @@
// @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// &@ @@ #@&
// @@ @. @@@ @@ ,@@. @/
// ,@@@ @@@@@@@( ,@@@ @@@@
//______________________________________________________________________________________________________________________
/*
*
*/
//----------------------------------------------------------------------------------------------------------------------
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#endif
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
using ll = long long;
using ld = long double;
int const MOD = 1000000007;
using namespace std;
int modpow(ll x, ll y);
vector<ll> primeFactors(ll n);
template<typename It>
ll gcdi(It s, It e) {
ll o = 0;
for (It i = s; i != e; ++i) { o = gcd(o, *i); }
return o;
}
template<typename It>
ll lcmi(It s, It e) {
ll o = 1;
for (It i = s; i != e; ++i) { o = lcm(o, *i); }
return o;
}
void solve() {
int n;
cin >> n;
if (n <= 2) {
cout << "0\n";
return;
}
int arr[n];
int freq[200];
for (int &i : freq)
i = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
freq[arr[i]]++;
// cout << freq[arr[i]] << ' ';
}
// cout << '\n';
int ans = 0;
for (int i : freq) {
if (i > 2)
ans++;
// cout << i << ' ';
}
cout << ans << '\n';
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
int modpow(ll x, ll y) {
ll res = 1;
x %= MOD;
if (x == 0) return 0;
while (y > 0) {
if (y & 1) res = (res * x) % MOD;
y = y >> 1;
x = (x * x) % MOD;
}
return (int) res;
}
vector<ll> primeFactors(ll n) {
vector<ll> f;
while (n % 2 == 0) {
f.eb(2);
n /= 2;
}
for (ll i = 3; i <= (ll) sqrt((double) n); i += 2) {
while (n % i == 0) {
f.eb(i);
n /= i;
}
}
if (n > 2) {
f.eb(n);
}
return f;
}