#include <bits/stdc++.h>

using namespace std;

#define  first
#define S second
#define ll long long
#define pb push_back
#define Mid ((L+R)/2)
#define pi pair<ll,ll>
#define pii pair<pi,int>
#define deb(x) cout<<#x<<"="<<x<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int t,n,b,mod=1e9+7;

int sum(int x,int y)
{
    x+=y;
    if(x>=mod)
        x-=mod;
    return x;
}

int sub(int x,int y){
    return sum(x-y,mod);
}

// 1. Dp[i-1][sumj] --> Dp[i][sumj+b] : just shift

// 2. Segma j : (Dp[i-1][sumj]) --> Dp[i][    b] : Sum of all last layer

int main()
{
    go;
    cin>>t;
    while(t--)
    {
        cin>>n;
        ll shift=0;
        int ans=1;
        map <ll,int> Dp;
        Dp[0]=1;
        while(n--)
        {
            cin>>b;
            int Ans=ans;
            ans=sum(ans,sub(ans,Dp[shift])); // 2 * Last layer - common when sumj = 0 (0+shift)
            shift-=b; // 1.
            Dp[shift+b]=Ans; // 2.
        }
        cout<<ans<<endl;
    }
    return 0;
}
