#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long &i : a) cin >> i;
  unordered_map<long long, bool> m;
  for (int i = 0; i < n; i++) {
    long long sum = a[i];
    for (int j = i + 1; j < n; j++) {
      sum += a[j];
      if (sum > n) break;
      m[sum] = true;
    }
  }
  long long count = 0;
  for (long long i : a) {
    count += m[i];
  }
  cout << count << "\n";
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
