#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const int maxn=212345;
int t,n,b[maxn];
int main()
{
    scanf("%d",&t);
    while (t--) {
        scanf("%d",&n);
        for (int i=1;i<=n;++i)
            scanf("%d",&b[i]);
        long long tot=0,sum=1;
        map<long long,long long> dp;
        dp[0]=1;
        for (int i=1;i<=n;++i) {
            long long add=(sum-dp[-tot]+mod)%mod;
            sum=(sum+add)%mod;
            dp[-tot]=(dp[-tot]+add)%mod;
            tot+=b[i];
        }
        printf("%I64d\n",sum);
    }
    return 0;
}
