#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll b[200005];
map<ll,ll> dp;
int main(){
	int t;
	cin>>t;
	while(t--){
		dp.clear();
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>b[i];
		}
		ll py=0,ans=1;
		dp[0]=1;
		for(int i=1;i<=n;i++){
			py-=b[i];
			ll t=ans-dp[b[i]+py];
			dp[b[i]+py]=ans;
			ans=ans+t%mod;
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}