#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n + 1), pre(n + 1), h(n + 1);
    for (int i = 1; i < n + 1; i++) {
      cin >> a[i];
      pre[i] = pre[i - 1] + a[i];
    }
    sort(a.begin(), a.end());
    int answer = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 2; j < n + 1; j++) {
        int no = pre[j] - pre[i];
        if (no <= n)
          h[no] = 1;
        else
          break;
      }
    }
    for (int i = 1; i < n + 1; i++)
      if (h[a[i]] == 1) answer++;
    cout << answer << "\n";
  }
  return 0;
}
