#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  bool vis[n + 1];
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= n - 1; i++) {
    int sum = a[i];
    for (int j = i + 1; j <= n; j++) {
      sum += a[j];
      if (sum > n) break;
      vis[sum] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[a[i]]) ans++;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int tests;
  cin >> tests;
  while (tests--) solve();
  return 0;
}
