#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#pragma GCC optimize("O3")
using namespace std;
using namespace std::chrono;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    int a[8005] = {0}, cnt[8005] = {0};
    for (int i = 0; i < (int)n; ++i) {
      cin >> a[i];
      cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < (int)n; ++i) {
      int temp = 0;
      for (int j = i; j < (int)n; ++j) {
        temp += a[j];
        if (i != j) {
          if (temp <= n) {
            ans += cnt[temp];
            cnt[temp] = 0;
          }
        }
      }
    }
    cout << ans;
    cout << '\n';
  }
  return 0;
}
