#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ht(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ht[a[i]]++;
  }
  int ps = 0, ans = 0, s;
  for (int i = 0; i < n; i++) {
    ps += a[i];
    s = 0;
    for (int j = 0; j < i; j++) {
      if (ps - s <= n && ht[ps - s]) {
        ans += ht[ps - s];
        ht[ps - s] = 0;
      }
      s += a[j];
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
