#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 200010;
const int MOD = 1e9 + 7;

int t, n; 
ll b[N], dp[N], pf[N], sum[N];

int main() {
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      scanf("%lld", b + i);
      pf[i] = pf[i - 1] + b[i];
    }
    dp[n + 2] = sum[n + 2] = 0;
    dp[n + 1] = sum[n + 1] = 1;
    map <ll, int> last;
    for (int i = n; i >= 0; --i) {
      dp[i] = dp[i + 1];
      if (b[i] != 0) {
        int pos = last.find(pf[i - 1]) == last.end() ? n : last[pf[i - 1]];
        dp[i] += sum[i + 2] - sum[pos + 2], dp[i] %= MOD;
        if (dp[i] < 0) dp[i] += MOD;
      }
      sum[i] = (sum[i + 1] + dp[i]) % MOD, last[pf[i]] = i;
    }
    printf("%lld\n", dp[0]);
  }
  return 0;
}

