#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const vector<T>& s) {
  for (auto x : s) cout << x << " ";
  cout << endl;
}
template <class T>
void print(const T* s, int n) {
  for (int i = 0; i < n; i++) cout << s[i] << ' ';
  cout << endl;
}
template <class T>
void print(vector<vector<T>> s) {
  for (int i = 0; i < s.size(); i++) print(s[i]);
}
int solve() {
  int n;
  cin >> n;
  vector<int> s(n);
  for (int& x : s) cin >> x;
  vector<int> pref(n + 1, 0);
  for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + s[i];
  vector<int> ok(n + 1);
  for (int l = 0; l < n; l++) {
    for (int r = l + 1; r < n; r++) {
      if (pref[r + 1] - pref[l] <= n) ok[pref[r + 1] - pref[l]] = 1;
    }
  }
  int cnt = 0;
  for (int x : s) cnt += ok[x];
  cout << cnt << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
