#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int INF = 1000000007;   const double EPS = 1e-10;   const double PI = 3.14159265359;   int n;   int a[200005];   int cnt[200005];   int main() {     int t;     cin >> t;     while (t--) {       set<int> st;       int mx = 0;       memset(cnt, 0, sizeof cnt);       cin >> n;       for (int i = 0; i < n; i++) {         cin >> a[i];         st.insert(a[i]);         cnt[a[i]]++;         mx = max(mx, cnt[a[i]]);       }       if (mx > st.size()) {         cout << st.size() << endl;       } else if (mx == st.size()) {         cout << mx - 1 << endl;       } else {         cout << mx << endl;       }     }     return 0;   }   