#include <bits/stdc++.h>
using namespace std;
int a[8100], pref[8100];
bool reach[8100];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      reach[i] = 0;
    }
    reach[n] = 0;
    pref[0] = a[0];
    for (int i = 1; i < n; i++) {
      pref[i] = pref[i - 1] + a[i];
      if (pref[i] <= n) reach[pref[i]] = 1;
      for (int j = 0; j < i - 1; j++) {
        if (pref[i] - pref[j] <= n) reach[pref[i] - pref[j]] = 1;
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      if (reach[a[i]]) ans++;
    cout << ans << '\n';
  }
  return 0;
}
