#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<int> s(n + 1);
    s[0] = 0;
    for (int i = 0; i < n; i++) {
      s[i + 1] = a[i] + s[i];
    }
    vector<int> v(n + 1, 0);
    for (int i = 0; i <= n - 2; i++) {
      for (int j = i + 2; j <= n; j++) {
        if (s[j] - s[i] > n) {
          break;
        } else {
          v[s[j] - s[i]] = 1;
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (v[a[i]] == 1) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
