#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf (int)(1e18)
#define md (int)(1e9+7)
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

const int M = 1e6 + 10;

// ai=bi
// ai=bi-(a1+..ai-1)
// a1+..ai-1=X
// X= 0 -> way[bi]=way[0]
// X= x -> way[bi]=way[x]  way[bi+x]=way[x]
// x-> x+b[i]
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   	
   	int tc;
   	cin>>tc;
   	while(tc--) {
   		int n;
   		cin>>n;
   		int b[n];
   		map<int,int> way;
   		way[0]=1;
   		int p=0,sum=1;
   		rep(i,0,n) {
   			cin>>b[i];
   			int val=sum;
   			p+=b[i];
   			sum-=way[b[i]-p];
   			way[b[i]-p]=val;
   			sum+=way[b[i]-p];
   			
   			if(sum>=md) sum-=md;
   			if(sum<0) sum+=md;
   		}
   		cout<<sum<<"\n";
   	}
   	
   	
    return 0;
}