#include <bits/stdc++.h>
using namespace std;
vector<long long> divisor(long long n) {
  vector<long long> d;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        d.push_back(i);
      } else {
        d.push_back(i);
        d.push_back(n / i);
      }
    }
  }
  return d;
}
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
}
int check_periodic(string s) {
  int n = s.length();
  int lps[n];
  lps[0] = 0;
  int i = 1;
  int len = 0;
  while (i < n) {
    if (s[i] == s[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
  int pl = lps[n - 1];
  if (len > 0 && n % (n - len) == 0) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> s(8001, 0);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      int sum = a[i];
      for (int j = i + 1; j < n; j++) {
        sum += a[j];
        if (sum >= 8001) {
          break;
        }
        s[sum] = 1;
      }
    }
    int c = 0;
    for (int i = 0; i < n; i++) {
      if (s[a[i]] == 1) {
        c++;
      }
    }
    cout << c << endl;
  }
  return 0;
}
