#include <bits/stdc++.h>
using namespace std;
void solve() {
  int A[8003];
  bool present[8003];
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) present[i] = false;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) {
      sum += A[j];
      if (sum > n) break;
      if (j - i > 0) present[sum] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (present[A[i]] == true) ans++;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
