#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

typedef long long LL;

const int MOD = 1000000007;

map<LL, LL> M;

int n;

int main() {

	int T;

	scanf("%d", &T);

	while (T--) {

		scanf("%d", &n);

		M.clear();

		M[0] = 1;

		LL rev = 0;

		LL sum = 1;

		LL x;

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

			scanf("%lld", &x);

			LL temp = ((sum - M[-rev]) % MOD + MOD) % MOD;

			rev += x;

			M[x - rev] = (M[x - rev] + temp) % MOD;

			sum = (sum + temp) % MOD;

		}

		printf("%lld\n", (sum + MOD) % MOD);

	}

}