#include <iostream>
#include <map>
#define ll long long
using namespace std;

const int N = 2e5 + 6, mod = 1e9 + 7;

map<ll, ll> H;
ll s[N];
int f[N];
int n;

int main() {
    // freopen("data.in", "r", stdin);
    int T; cin >> T;
    while(T--) {
        H.clear();
        cin >> n;
        for(int i = 1; i <= n; i ++) {
            cin >> s[i];
            s[i] += s[i-1];
        }
        ll sum;
        f[1] = sum = 1;
        H[s[0]] = 1;
        for(int i = 2; i <= n; i ++) {
            f[i] = sum;
            f[i] = (f[i] - H[s[i-1]] + mod) % mod;
            // for(int k = 1; k <= i-1; k ++)
            //     if(s[i-1] == s[k-1]) f[i] = (f[i] - f[k] + mod) % mod;
            sum = (sum + f[i]) % mod;
            H[s[i-1]] = (H[s[i-1]] + f[i]) % mod;
        }
        cout << sum << endl;
    }
}