#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int n;
int arr[8005];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    multiset<int> ms;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      ms.insert(arr[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int sum = arr[i];
      for (int j = i + 1; j < n; j++) {
        sum += arr[j];
        while (ms.find(sum) != ms.end()) {
          ans++;
          ms.erase(ms.find(sum));
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
