#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 2e5+5;
const ll M = 1e9+7;

ll n;
ll b[N];

map<ll,ll> dp; 
//dp[i] represents hybrid array count with sum i

int main(){
    ll t;
    cin >> t;
    while (t--){
        cin >> n;
        dp.clear();
        for (ll i = 0; i<n; i++){
            cin >> b[i];
        }

        ll w = 0;
        //venice technique - water level
        //optimize transition from all dp[j] -> dp[j+bi]
        
        dp[0] = 1;
        ll sum = 1;
        for (ll i = 0; i<n; i++){
            ll p = dp[-w];
            dp[-w] = sum;
            w += b[i];
            sum = (2*sum-p+M)%M;
        }
        cout << sum << endl;
    }
}
