#include <bits/stdc++.h>
using namespace std;
const long long INFLL = LLONG_MAX;
const int INF = INT_MAX;
const long long MAXLL = 0x3f3f3f3f3f3f3f3f;
const int MAX = 0x3f3f3f3f;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class T>
void sort(vector<T>& v) {
  sort(v.begin(), v.end());
}
template <class T, class U>
void sort(vector<T>& v, U func) {
  sort(v.begin(), v.end(), func);
}
template <class T>
int lb_index(vector<T>& v, T k) {
  return lower_bound(v.begin(), v.end(), k) - v.begin();
}
template <class T>
int ub_index(vector<T>& v, T k) {
  return upper_bound(v.begin(), v.end(), k) - v.begin();
}
void solve() {
  int n;
  cin >> n;
  vector<int> v(n + 1), c(n + 1), p(n + 1), b(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    p[i] = p[i - 1] + v[i];
    c[v[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int l = p[j] - p[i - 1];
      if (l > n) break;
      b[l] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans += c[i];
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
