#include <bits/stdc++.h>
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
constexpr int P = 1e9 + 7;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int tt;
	std::cin >> tt;
	while (tt--) {
		int n;
		std::cin >> n;
		std::vector<int> b(n + 1);
		for (int i = 1; i <= n; i++) {
			std::cin >> b[i];
		}
		std::map<i64, int> map;
		i64 qwq = 0;
		int ans = map[0] = 1;
		for (int i = 1; i <= n; i++) {
			int nxt = map[b[i] - (qwq += b[i])];
			map[b[i] - qwq] = ans;
			ans += map[b[i] - qwq];
			if (ans >= P) {
				ans -= P;
			}
			ans -= nxt;
			if (ans < 0) {
				ans += P;
			}
		}
		std::cout << ans << "\n";
	}
	return 0;
}