#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const ll M = 1000000007;

int n, b[200200];
void solve() {
	vector<ll> p(n + 1);
	for (int i = 1; i <= n; i++) {
		p[i] = p[i-1] + b[i];
	}
	map<ll, ll> pd;
	pd[0] = 1;
	vector<ll> f(n + 1), g(n + 1);
	f[0] = g[0] = 1;
	for (int i = 1; i <= n; i++) {
		f[i] = (f[i-1] * 2 - g[i-1] + M) % M;
		g[i] = pd[p[i]];
		pd[p[i]] = (pd[p[i]] + f[i] - g[i] + M) % M;
		//cout << i << ": " << f[i] << " " << g[i] << endl;
	}
	cout << f[n] << endl;
}
int main() {
	// your code goes here
	int t;
	scanf("%d\n", &t);
	for (int i = 0; i < t; i++) {
		scanf("%d\n", &n);
		for (int j = 1; j <= n; j++) {
			scanf("%d\n", b + j);
		}
		solve();
	}
	return 0;
}