#include <bits/stdc++.h>
using namespace std;
int n, cnt, sum;
int a[8001];
int m[8001];
void itsHerChoice() {
  cin >> n;
  for (int i = 0; i < n + 1; i++) m[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    sum = a[i];
    for (int j = i + 1; j < n; j++) {
      sum += a[j];
      if (sum <= n)
        if (m[sum] > 0) {
          cnt += m[sum];
          m[sum] = 0;
        }
    }
  }
  cout << cnt << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test;
  test = 1;
  cin >> test;
  while (test--) {
    itsHerChoice();
  }
  cerr << "\n"
       << "समय गुज़रा : " << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
  return 0;
}
