#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    unordered_map<int, int> seen;
    for (int i = 0; i < n - 1; i++) {
      int sum = a[i];
      for (int r = i + 1; r < n; r++) {
        sum += a[r];
        if (sum > n) break;
        seen[sum] = 1;
      }
    }
    for (int i : a) {
      ans += seen[i];
    }
    cout << ans << endl;
  }
}
