#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long pqr = 0; pqr < n; ++pqr) cin >> v[pqr];
  ;
  long long i = 0, j = 0, sum = 0;
  vector<long long> ans(n + 1, 0);
  long long ank = 0;
  for (long long k = 0; k < n; ++k) {
    if (ans[v[k]] != 0) {
      ank++;
      continue;
    }
    sum = 0;
    i = 0;
    j = 0;
    while (j < n) {
      sum += v[j];
      j++;
      if (sum == v[k] && (j - i) >= 2) {
        ank++;
        break;
      }
      while (i < j && sum > v[k]) {
        sum -= v[i];
        i++;
      }
      if (sum == v[k] && (j - i) >= 2) {
        ank++;
        break;
      }
    }
  }
  cout << ank << endl;
}
int main() {
  time_t start, end;
  time(&start);
  time(&end);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
