#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define mset(a, b) memset(a, b, sizeof(a))
#define cpy(a,b) memcpy(a, b, sizeof(a))
#define fornext(x, i) for(signed i = hd[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define Rep(i, a, b) for(signed i = (signed)(a); i <= (signed)(b); ++i)
#define dRep(i, a, b) for(signed i = (signed)(a); i >= (signed)(b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define pb push_back
#define It iterator
#define endl '\n'
#define un unsigned
#define int ll
#define ll long long
#define db double
#define rept cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#define dbg cout<<"c "
#define dbug(x) cerr << #x " = " << (x) << endl
template<typename _T> inline void _prt(_T _d) { cerr << _d << ' '; }
template <typename _T, typename ...Args> inline void _prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...); }
template <typename _T, typename ...Args> inline void prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...), cerr<<endl; }
template <typename _T, typename ...Args> inline void prt(_T _d) { cerr << _d <<endl; }
template<typename _T> inline void rd(_T &_d) {
	signed _f; char _c; _f = 1,_d = 0; while (_c = getchar(), !isdigit(_c)) if(_c=='-') _f=-1;
	while (isdigit(_c)) _d = _d * 10 + _c - '0', _c = getchar();
	_d=_f*_d;
}
template <typename _T, typename ...Args> inline void rd(_T &_d, Args &..._a) { rd(_d); rd(_a...); }

const int N=2e5+5,M=1e9+7;
int n,a[N],b[N],f[N];

inline int md(int x) {
	return x>=M?x-M:x;
}

signed main() {
	int T,sum,tmp;
	rd(T);
	while(T--) {
		rd(n);
		a[0]=0;
		Rep(i,1,n) rd(a[i]);
		Rep(i,1,n) a[i]+=a[i-1];
		Rep(i,1,n) b[i]=a[i];
		b[n+1]=0;
		sort(b+1,b+n+2);
		int w=unique(b+1,b+n+2)-b-1;
		Rep(i,1,w) f[i]=0;
		Rep(i,0,n) a[i]=lower_bound(b+1,b+w+1,a[i])-b;
		sum=f[a[0]]=1;
		Rep(i,2,n) {
			tmp=md(sum-f[a[i-1]]+M),f[a[i-1]]=sum,sum=md(sum+tmp);
		}
		cout<<sum<<endl;
	}
	return 0;
}