#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:360777216")
using LL = long long;
int M = 1000000007;
int INF = INT_MAX - 1000;
int P = 31;
using namespace std;
int t, n, m, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (int(ii) = (0); (ii) < (t); ++(ii)) {
    cin >> n;
    vector<int> a(n), pref(n), used(n + 1, 0);
    for (int(i) = (0); (i) < (n); ++(i)) {
      cin >> a[i];
      used[a[i]]++;
      pref[i] = a[i];
      if (i != 0) pref[i] += pref[i - 1];
    }
    int ans = 0;
    for (int(i) = (0); (i) < (n); ++(i)) {
      if (i != 0 && pref[i] <= n) {
        ans += used[pref[i]];
        used[pref[i]] = 0;
      }
      for (int(j) = (i + 2); (j) < (n); ++(j)) {
        int sum = pref[j] - pref[i];
        if (sum > n) continue;
        ans += used[sum];
        used[sum] = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
