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

using namespace std;

int main()
{
	vector<int> a;
	vector<long long> bb;
	map<long long, long long> convert_num;
	int t;
	cin >> t;
	long long n;
	while (t--)
	{
		cin >> n;
		a.resize(n);
		bb.resize(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];
		}
		long long ans1 = 0;
		long long ans2 = 1;
		convert_num.clear();
		convert_num[bb[0]] = 1;
		for (int i = 1; i < n; i++)
		{
			ans1 = ans2;
			ans2 = (1000000007 + 2 * ans2 - convert_num[bb[i]]) % 1000000007;
			convert_num[bb[i]] = ans1;
		}
		cout << ans2 << endl;


	}
	return 0;
}