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