#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int MAX_N = 1e5 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> srt(n + 1);
  srt.assign(n + 1, 0);
  for (long long i = 0; i < int(n); i++) {
    cin >> a[i];
    srt[a[i]]++;
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    long long sum = 0, cnt = 0;
    for (int j = i; j < n; ++j) {
      sum += a[j];
      cnt++;
      if (sum <= n && srt[sum] > 0 && cnt > 1) {
        res += srt[sum];
        srt[sum] = 0;
      }
    }
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
