#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ar[8001] = {0};
    vector<int> v(n);
    for (int& x : v) {
      cin >> x;
      ar[x]++;
    }
    int ans = 0;
    for (auto i = (0); i <= (n - 1); i++) {
      int sum = v[i];
      for (auto j = (i + 1); j <= (n - 1); j++) {
        sum = sum + v[j];
        if (sum > n) break;
        ans = ans + ar[sum];
        ar[sum] = 0;
      }
    }
    cout << ans;
    cout << "\n";
    ;
  }
  return 0;
}
