#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
    if (a + b < MOD) {
        return a + b;
    }
    return a + b - MOD;
}

int sub(int a, int b) {
    if (a >= b) {
        return a - b;
    }
    return a - b + MOD;
}

void solve() {
    int n;
    cin >> n;
    vector<int> b(n);
    for (auto &t : b) {
        cin >> t;
    }
    vector<int> ps(n + 1);
    for (int i = 0; i < n; i++) {
        ps[i + 1] = ps[i] + b[i];
    }
    vector<int> all(n + 1);
    map<int, int> last;
    function<int(int, int)> solve = [&](int i, int x) {
        if (i == 0) {
            return (int)(x == 0);
        }
        int f = b[i - 1];
        if (x == f) {
            return all[i - 1];
        } else {
            if (last.count(x - ps[i])) {
                int j = last[x - ps[i]];
                return solve(j, x - ps[i] + ps[j]);
            } else {
                return solve(0, x - ps[i]);
            }
        }
    };
    all[0] = 1;
    for (int i = 0; i + 1 <= n; i++) {
        all[i + 1] = add(all[i], all[i]);
        all[i + 1] = sub(all[i + 1], solve(i, 0));
        if (i - 1 >= 0) last[b[i - 1] - ps[i]] = i;
    }
    cout << all[n] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int q;
    cin >> q;
    while (q--) {
        solve();
    }
}
