#include <bits/stdc++.h>
using namespace std;
const long long mx = 8010;
long long ele[mx];
bool visit[mx];
void solve() {
  long long n;
  cin >> n;
  memset(visit, false, sizeof visit);
  for (long long i = 0; i < n; i++) cin >> ele[i];
  for (long long i = 0; i < n; i++) {
    long long temp = ele[i];
    for (long long j = i + 1; j < n; j++) {
      temp += ele[j];
      if (temp > n) break;
      visit[temp] = true;
    }
  }
  long long count = 0;
  for (long long i = 0; i < n; i++)
    if (visit[ele[i]]) count++;
  cout << count << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
