#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int N = 200010;
int T;
long long a[N], sum[N];
map<long long, int> m;
vector<int> v;
signed main() {
cin >> T;
while (T--) {
m.clear(); v.clear();
int n; cin >> n;
for (int i = 1; i <= n; i++) scanf("%lld", a + i), sum[i] = sum[i - 1] + a[i];
int tot = n + 1;
for (int i = 1; i <= n; i++)
if (a[i] == 0) v.push_back(i);
int ans = 0, res = 0;
if (v.empty()) {
for (int i = 1; i <= n; i++)
if (sum[i] == 0) ans++;
printf("%d\n", ans);
continue;
}
for (int i = 1; i < v[0]; i++)
if (sum[i] == 0) ans++;
for (int i = 0; i < v.size() - 1; i++) {
int x = v[i], y = v[i + 1] - 1;
m.clear(); res = 0;
while (x <= y) {
m[sum[x]]++;
res = max(res, m[sum[x]]);
x++;
}
ans += res;
}
m.clear(); res = 0;
for (int i = v[v.size() - 1]; i <= n; i++) {
m[sum[i]]++;
res = max(res, m[sum[i]]);
}
printf("%d\n", ans + res);
}
return 0;
}