#include <bits/stdc++.h>
using namespace std;
int s[8005];
int a[8005];
unordered_map<short, bool> d;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int jsq = 0;
    s[0] = 0;
    for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (s[j] - s[i - 1] > n) break;
        d[s[j] - s[i - 1]] = 1;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (d[a[i]] == 1) jsq++;
    }
    cout << jsq << endl;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        d[s[j] - s[i - 1]] = 0;
      }
    }
  }
  return 0;
}
