#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;

		map <ll, int> mp;
		mp[0] = 0;
		ll sum = 0;

		vector <int> dp1(n + 1, 0), dp2(n + 1, 0);
		dp1[0] = dp2[0] = 1;

		for(int i = 1; i <= n; i++) {
			int x;
			cin >> x;

			dp1[i] = ((2 * dp1[i - 1]) % mod - dp2[i - 1] + mod) % mod;
			sum += x;
			if(mp.find(sum) != mp.end()) dp2[i] = dp1[mp[sum]];
			mp[sum] = i;
		}
		cout << dp1[n] << '\n';
	}
}