#include <bits/stdc++.h>
using namespace std;
long long getPref(long long l, long long r, vector<long long>& pref) {
  return pref[r] - pref[l - 1];
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> pref(n + 1), arr(n + 1);
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    arr[x]++;
    pref[i] = pref[i - 1] + x;
  }
  long long cnt = 0;
  for (long long len = 2; len <= n; len++) {
    for (long long l = 1; l + len <= n + 1; l++) {
      long long r = l + len - 1;
      long long pr = getPref(l, r, pref);
      if (1 <= pr && pr <= n && arr[pr] > 0) {
        cnt += arr[pr];
        arr[pr] = 0;
      }
    }
  }
  cout << cnt << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
