#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
const int inf=1<<30;

const int N=200005;
const int p=1000000007;
ll b[N],s[N],tmp[N];ll lst[N];ll dp[N];
int main()
{
	int _T_=rd();while(_T_--)
	{
		int n=rd();
		F(i,1,n) tmp[i]=s[i]=s[i-1]+rd(b[i]);tmp[0]=0;
		sort(tmp,tmp+n+1);F(i,0,n) lst[i]=n+1;
		dp[0]=1;dp[1]=1;lst[lower_bound(tmp,tmp+n+1,s[0])-tmp]=0;dp[n+1]=0;
		F(i,2,n)
		{
			int pos=lower_bound(tmp,tmp+n+1,s[i-1])-tmp;
			dp[i]=((2*dp[i-1]-dp[lst[pos]])%p+p)%p;
			lst[pos]=i-1;
		}
		printf("%lld\n",dp[n]);
	}
	return 0;
}
/*
4
3
1 -1 1
4
1 2 3 4
10
2 -1 1 -2 2 3 -5 0 2 -1
4
0 0 0 1

3
8
223
1

*/