import os
import sys
input=sys.stdin.readline
a=int(input())
from collections import *
for i in range(a):
    s=int(input())
    z=list(map(int,input().split()))
    al=defaultdict(int)
    flag=0
    cnt=0
    maxa=0
    total=0
    for i in range(len(z)):
        if(flag==0 and z[i]!=0):
            cnt+=z[i]
            if(cnt==0):
                total+=1
            continue
        
        if(flag==0 and z[i]==0):
            al[cnt]=1
            flag=1
            maxa=1
            ind=z[i]
            continue

        if(flag!=0 and z[i]!=0):
            cnt+=z[i]
            al[cnt]+=1
            if(al[cnt]>maxa):
                maxa=al[cnt]
                ind=cnt
            continue

        if(flag!=0 and z[i]==0):
            total+=maxa
            cnt-=ind
            al.clear()
            al[cnt]=1
            maxa=1
            ind=cnt
    
    
    total+=maxa
    print(total)