#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> cnt(n + 1, 0);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      cnt[v[i]]++;
    }
    long long sum = 0, ans = 0, len = 0;
    for (int i = 0; i < n; i++) {
      sum = v[i], len = 1;
      for (int j = i + 1; j < n; j++) {
        sum += v[j];
        len++;
        if (len >= 2) {
          if (sum <= n) {
            ans += cnt[sum];
            cnt[sum] = 0;
          } else
            break;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
