#include<bits/stdc++.h> #define re register #define ll long long
usingnamespace std;
constint N = 2e5 + 10; int T,n; int arr[N]; ll s[N];
inlineintread(){ int r = 0,w = 1; char c = getchar(); while (c < '0' || c > '9'){ if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9'){ r = (r << 1) + (r << 3) + (c ^ 48); c = getchar(); } return r * w; }
intmain(){ T = read(); while (T--){ int ans = 0,len = 0; vector<int> v; n = read(); for (re int i = 1;i <= n;i++) arr[i] = s[i] = 0; for (re int i = 1;i <= n;i++){ arr[i] = read(); s[i] = s[i - 1] + arr[i]; if (!arr[i]){ len++; v.push_back(i); } } v.push_back(n + 1); for (re int i = 1;i < v.front();i++){ if (!s[i]) ans++; } for (re int x = 0;x < len;x++){ unordered_map<ll,int> vis; int Max = 0; for (re int i = v[x];i < v[x + 1];i++){ vis[s[i]]++; Max = max(Max,vis[s[i]]); } ans += Max; } printf("%d\n",ans); } return0; }