#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long MAX = 2e5 + 5;
long long n = 0, i = 0, j = 0;
void solve() {
  cin >> n;
  vector<long long> v(n);
  long long mp[n + 1];
  memset(mp, 0, sizeof(mp));
  for (long long i = (0); i < (n); i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  long long ans = 0;
  for (long long i = (1); i < (n); i++) v[i] += v[i - 1];
  for (i = 0; i <= n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      long long sum = 0;
      if (i == 0)
        sum = v[j];
      else
        sum = v[j] - v[i - 1];
      if (sum > n) break;
      ans += mp[sum];
      mp[sum] = 0;
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long loser = 1;
  cin >> loser;
  while (loser--) {
    solve();
    cout << "\n";
  }
  return 0;
}
