#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, ans = 0, maxi = 0;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n + 1, 0);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      b[a[i]]++;
      maxi = max(maxi, a[i]);
    }
    for (long long i = 0; i < n; i++) {
      long long temp = a[i];
      for (long long j = i + 1; j < n; j++) {
        temp += a[j];
        if (temp > maxi) break;
        if (b[temp] != 0) {
          ans += b[temp];
          b[temp] = 0;
        }
      }
    }
    cout << ans << endl;
  }
}
