#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    unordered_map<long long int, long long int> s;
    long long int a[n + 1];
    a[0] = 0;
    for (long long int i = 1; i < n + 1; i++) {
      long long int temp;
      cin >> temp;
      auto it = s.find(temp);
      if (it != s.end()) {
        (*it).second++;
      } else {
        s.insert(make_pair(temp, 1));
      }
      a[i] = temp + a[i - 1];
    }
    long long int ans = 0;
    for (long long int i = 2; i < n + 1; i++) {
      for (long long int j = 0; j < i - 1; j++) {
        auto it = s.find(a[i] - a[j]);
        if (it != s.end()) {
          ans += (*it).second;
          s.erase(it);
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
