#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(0);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    int pref[n + 1];
    pref[0] = 0;
    int max = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      pref[i] = pref[i - 1] + a[i];
      if (a[i] > max) max = a[i];
    }
    int answer = 0;
    int is[n + 1];
    for (int i = 1; i <= n; ++i) {
      is[i] = 0;
    }
    for (int i = 1; i < n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        int sn = pref[j] - pref[i - 1];
        if (sn <= n) is[sn] = 1;
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (is[a[i]]) answer++;
    }
    cout << answer << endl;
  }
  return 0;
}
