#include <bits/stdc++.h>
using namespace std;
typedef int64_t g;
g n,p[269420],v=1e9+7,T,r,i,k,s;
map<g,g> l;
int main(){
cin>>T;
while(T--){
cin>>n;
l.clear();
for(i=0,s=0,p[0]=1,l[0]=1;++i<=n;){
cin>>k;
p[i]=(p[i-1]*2+v-p[l[s]-1])%v;
l[s]=i;
s+=k;
}cout<<p[n]<<endl;
}
}