#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<int> b(n);
        for (auto& i : b) {
            cin >> i;
        }
        int res = 1, d = 0, sum = 1;
        map<int, int> dp;
        dp[0] = 1;
        for (int i = 0; i < n; i++) {
            d += b[i];
            int pre = dp[b[i] - d];
            dp[b[i] - d] = res;
            res = res + res - pre;
            res = (res % mod + mod) % mod;
        }
        cout << res << '\n';
    }
    return 0;
}