#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 4;
long long add(long long a, long long b, long long m) {
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = ((a % m) + (b % m)) % m;
  res %= m;
  return res;
}
long long mul(long long a, long long b, long long m) {
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = ((a % m) * (b % m)) % m;
  res %= m;
  return res;
}
long long sub(long long a, long long b, long long m) {
  long long res = (a - b + m) % m;
  res %= m;
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n + 1);
    unordered_map<long long, long long> mp;
    unordered_set<long long> st;
    vector<long long> pref(n + 1, 0);
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      pref[i] = pref[i - 1] + a[i];
      if (mp.find(a[i]) == mp.end())
        mp[a[i]] = 1;
      else
        mp[a[i]]++;
    }
    long long res = 0;
    for (long long l = 2; l < n; l++) {
      for (long long i = 1; i <= n - l + 1; i++) {
        long long j = i + l - 1;
        if (mp.find(pref[j] - pref[i - 1]) == mp.end() or
            st.find(pref[j] - pref[i - 1]) != st.end())
          continue;
        res += mp[pref[j] - pref[i - 1]];
        st.insert(pref[j] - pref[i - 1]);
      }
    }
    cout << res << '\n';
  }
  return 0;
}
