#include <cstdio>
#include <map>

using namespace std;

#define int long long

const int mod = 1000000007;

int n, b[200005];

signed main() {
//    freopen("in", "r", stdin), freopen("out", "w", stdout);
    int Test;
    scanf("%lld", &Test);
    while (Test--) {
        scanf("%lld", &n);
        for (int i = 1; i <= n; i++)scanf("%lld", &b[i]);
        map<int, int> mp;
        mp[0] = 1;
        int ans = 1;
        for (int i = 1, k = 0; i <= n; i++) {
            int temp = mp[k];
            mp[k] = ans;
            ans = 2 * ans - temp;
            ans += mod, ans %= mod;
            k -= b[i];
        }
        printf("%lld\n", ans);
    }
    return 0;
}