/*
author: Edward Johnson(Manchester_UNITED)
problem: Codeforces Round #701-F
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define inf 1000000000
#define inf64 1000000000000000000
#define X first
#define Y second
#define ll long long
#define mod 1000000007
using namespace std;
const int maxn=202020;
ll n,b[maxn],id[maxn],sum[maxn],dp[maxn],dpid[maxn];
vector<ll> ts;
void solve(){
	scanf("%lld",&n);
	ts.clear();
	sum[0]=0;
	for(int i=0;i<=n;i++) dpid[i]=0;
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]),sum[i]=sum[i-1]+b[i],ts.pb(sum[i-1]);
	sort(ts.begin(),ts.end());
	ts.erase(unique(ts.begin(),ts.end()),ts.end());
	for(int i=0;i<=n;i++) dp[i]=0,id[i]=lower_bound(ts.begin(),ts.end(),sum[i-1])-ts.begin();
	dp[0]=1;
	dpid[id[0]]=1;
	ll sum0=1;
	for(int i=1;i<=n;i++){
		dp[i]=(sum0+mod-dpid[id[i]])%mod;
		dpid[id[i]]=(dpid[id[i]]+dp[i])%mod;
		sum0=(sum0+dp[i])%mod;
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans=(ans+dp[i])%mod;
	printf("%lld\n",ans);
	return;
}
int main(){
	ll t;
	scanf("%lld",&t);
	for(int tc=0;tc<t;tc++) solve();
	return 0;
}