#include<bits/stdc++.h>
#define re register
#define N 2001001
#define inf 1e18
#define MAX 1101
using namespace std;
typedef long long ll;
typedef double db;
const ll mod=1000000007;
inline void read(re ll &ret)
{
	ret=0;re char c=getchar();re bool pd=false;
	while(!isdigit(c)){pd|=c=='-';c=getchar();}
	while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c&15);c=getchar();}
	ret=pd?-ret:ret;
	return;
}
ll t,n,a[N],b[N];
map<ll,ll>mp; 
signed main()
{
	read(t);
	while(t--)
	{
		read(n);
		for(re int i=1;i<=n;i++)
			read(b[i]);
		mp.clear();
		re ll now=-b[1],ans=1;
		mp[0]=1;
		for(re int i=2;i<=n;i++)
		{
			re ll tmp=mp[now];
			mp[now]=ans;
			now-=b[i];
			ans=((ans<<1)-tmp);
			ans=(ans%mod+mod)%mod;
		}
		printf("%lld\n",ans);
	}
	exit(0);
}