#include<bits/stdc++.h>
#define ll long long
using namespace std;
const long o=200005,M=1e9+7;
long n,b[o];
map<ll,long>sl;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long test; cin>>test;
    while(test--)
    {
        cin>>n;
        for(long i=1;i<=n;i++)
            cin>>b[i];
        sl.clear(); sl[0]=1;
        ll kq=1,tong=b[1];
        for(long i=2;i<=n;i++)
        {
            ll kqc=kq,sl0=sl[-tong];

            kqc=(kqc-sl0+M)%M;
            kq=(kq+kqc)%M;

            tong+=b[i];
            sl[b[i]-tong]=(sl[b[i]-tong]+kqc)%M;
        }
        cout<<kq<<'\n';
    }
    return 0;
}
