#include <bits/stdc++.h>
const int INF = int(1e9);
const int N = 2e5 + 5;
const int mod = 1000000007;
using namespace std;
int binpow(int x, int y) {
  int z = 1;
  while (y) {
    if (y % 2) z = (z * x) % mod;
    y = y / 2;
    x = (x * x) % mod;
  }
  return z % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int tc = 1;
  cin >> tc;
  while (tc--) {
    int n, k, m, i;
    cin >> n;
    std::vector<int> a(n);
    int mx = 0, cnt[8005] = {0}, f[8005] = {0};
    for (i = 0; i < n; i++) {
      cin >> a[i];
      mx = max(mx, a[i]);
      cnt[a[i]]++;
    }
    int ans = 0;
    for (i = 0; i < n - 1; i++) {
      int sum = a[i];
      for (int j = i + 1; j < n; j++) {
        sum += a[j];
        if (sum > mx) break;
        if (sum > 0 and cnt[sum] > 0 and f[sum] == 0) {
          ans += cnt[sum];
          f[sum] = 1;
        }
      }
    }
    cout << ans << endl;
  }
}
