#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7, N1 = 1e7 + 5, N2 = 1e6 + 3, N3 = 1e5 + 3;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t1 = 1;
  cin >> t1;
  while (t1--) {
    long long n;
    cin >> n;
    vector<long long> a(n), v(n + 1, 0);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long maxi = *max_element(a.begin(), a.end()), sum = 0, cnt = 0;
    set<long long> ss;
    for (long long i = 0; i < n; i++) {
      sum = 0;
      sum += a[i];
      for (long long j = i + 1; j < n; j++) {
        sum += a[j];
        if (sum <= maxi)
          v[sum]++;
        else
          break;
      }
    }
    for (long long i = 0; i < n; i++) {
      if (v[a[i]] > 0) cnt++;
    }
    cout << cnt;
    cout << endl;
  }
}
