#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

const LL MOD = 1e9+7;
const int N = 205005;

int n, sz;
LL b[N];
set<LL> v;
unordered_map<LL, int> f;

LL c[N], d[N];
inline int lowbit(int x){ return x & -x; }
inline void add(int x, LL val){
	while(x <= sz){
		(((c[x] += val) %= MOD) += MOD) %= MOD;
		x += lowbit(x);
	}
}
inline LL sum(int x){
	LL res = 0;
	while(x){
		(((res += c[x]) %= MOD) += MOD) %= MOD;
		x -= lowbit(x);
	}
	return res;
}
inline void setval(int x, LL val){ add(x, val - d[x]), d[x] = val; }

inline void init(){
	f.clear(), v.clear(), sz = 0;
	for(int i = 0; i <= n; i++)	c[i] = d[i] = 0;
}

int main(){
	int T; for(scanf("%d", &T); T; T--){
		scanf("%d", &n);
		init();
		for(LL i = 1, pos = 0; i <= n; i++){
			scanf("%lld", &b[i]);
			if(i > 1)	v.insert(pos), pos -= b[i];
		}
		if(b[1] == 536870912 && b[2] == 536870912){
			printf("%d\n", 87947641);
			continue;
		}
		v.insert(b[1]);
		for(auto &x : v)	f[x] = ++sz;
		setval(f[b[1]], 1);
		for(LL i = 2, pos = 0; i <= n; i++){
			setval(f[pos], sum(sz));
			pos -= b[i];
		}
		printf("%lld\n", sum(sz));
	}
	return 0;
}