#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
const int mod=1e9+7;
//define si is the sigema aj (1<=j<=i)
map<long long,long long>cnt;//cnt[i] is the number when the si is i
int main(){
	int T=read();
	for(int t=1;t<=T;++t){
		int n=read();
		cnt.clear();
		long long deta=0;
		long long sum=1;
		cnt[0]=1;
		for(int i=1;i<=n;++i){
			int x=read();
			long long add=sum-cnt[0-deta];
			sum=(sum+add)%mod;
			deta+=x;
			cnt[x-deta]=(cnt[x-deta]+add)%mod;
		}
		printf("%lld\n",(sum%mod+mod)%mod);
	}
	return 0;
}