#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
const int mod = 998244353;
int powmod(int a, int b) {
  int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const auto start_time = std::chrono::high_resolution_clock::now();
void prophet123() {}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int sum[8001];
    memset(sum, 0, sizeof(sum));
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      int temp = a[i];
      for (int j = i + 1; j < n; j++) {
        temp += a[j];
        if (temp > 8000) break;
        ans += sum[temp];
        sum[temp] = 0;
      }
    }
    cout << ans << "\n";
  }
  prophet123();
  return 0;
}
