#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
void solve()
{
    int n;
    cin >> n;
    ll b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    map<ll, ll> d;
    d[0] = 1;
    ll t = 1, k = 0;
    for (int i = 0; i < n; i++)
    {
        ll a = d[k];
        d[k] = t;
        k += b[i];
        t = (2 * t - a + mod) % mod;
        // cout << t << ' ' << k << '\n';
    }
    cout << t << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt = 1;
    cin >> tt;
    while (tt--)
    {
        solve();
    }
    return 0;
}