#include <bits/stdc++.h>
using i64 = long long;
void solve() {
int n;
std::cin >> n;
std::map<int, int> cnt;
for (int i = 0; i < n; i++) {
int x;
std::cin >> x;
cnt[x]++;
}
int s = 0;
int t = std::min(cnt[1], cnt[-1] / 2);
s += t;
cnt[1] -= t;
cnt[-1] -= t * 2;
t = cnt[1] / 3;
s += t;
cnt[1] -= t * 3;
t = std::min(cnt[0], (cnt[1] + cnt[-1]) / 2);
int c = cnt[0] + cnt[1] + cnt[-1];
c -= 3 * t;
if (cnt[0] == t) {
s -= c / 3;
}
std::cout << s << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
}