#include <iostream>
#include <map>
#define ll long long
#define MOD 1000000007
#define NMAX 200000

using namespace std;

ll t, sp[NMAX+10], v[NMAX+10], ans[NMAX+10];
map <ll, ll> fr;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	while(t--)
		{	int n, m = 0;
			cin >> n;
			fr.clear();
			for(int i=1; i<=n; i++)
				{	int x;
					cin >> v[i];
					sp[i] = sp[i-1] + v[i];
					ans[i] = 0;
				}
			ans[1] = 1;
			fr[0] = 1;
			for(int i=2; i<=n; i++)
				{	ans[i] = ans[i-1] * 2 % MOD;
					ll nr = fr[sp[i-1]];
					ans[i] = (ans[i] - nr + MOD) % MOD;
					fr[sp[i-1]] = ans[i-1];
				}
			cout << ans[n] << '\n';
		}	
	return 0;
}