#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main()
{
	int a[2 * 100000];
	long long bb[2 * 100000 + 1];
	pair<long long, long long> b[2 * 100000 + 1];
	long long ans[2 * 100000 + 1];
	map<long long, long long> convert_num;
	int t;
	cin >> t;
	for (int ii = 0; ii < t; ii++)
	{
		long long n;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		bb[0] = 0;
		for (int i = 1; i < n; i++)
		{
			bb[i] = bb[i - 1] + a[i - 1];
		}
		for (int i = 0; i < n; i++)
		{
			convert_num[bb[i]] = 0;
		}
		ans[0] = 1;
		convert_num[bb[0]] = 1;
		for (int i = 1; i < n; i++)
		{
			ans[i] = (1000000007 + 2*ans[i-1] - convert_num[bb[i]]) % 1000000007;
			convert_num[bb[i]] = ans[i - 1];
		}
		cout << ans[n-1] << endl;


	}
	return 0;
}