#include <bits/stdc++.h>
using namespace std;
char x[200010], y[200010], z[200010];
int main() {
  int n, t, i, j, k, f = 0, mn, m, dif = 0, pos, mx, l;
  long long int sum = 0;
  cin >> t;
  while (t--) {
    mx = 0, f = 0;
    cin >> n;
    vector<int> v(n);
    for (i = 0; i < n; i++) {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    j = v[0];
    for (i = 1; i < n; i++) {
      if (v[i] == j) {
        v[i] = 0;
      } else {
        j = v[i];
      }
    }
    for (i = 0; i < n; i++) {
      if (v[i] != 0) f++;
    }
    cout << f << endl;
  }
  return 0;
}
