#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a[8010], b[8010], c[8010], d[8010], sum, i, j;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    memset(d, 0, sizeof(d));
    sum = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> a[i];
      b[i] = b[i - 1] + a[i];
      d[a[i]]++;
    }
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++) {
        if (b[j] - b[i - 1] <= n) c[b[j] - b[i - 1]]++;
      }
    for (i = 1; i <= n; i++)
      if (c[a[i]] != 0 && d[a[i]] != 0) {
        sum += d[a[i]];
        d[a[i]] = 0;
      }
    cout << sum << endl;
  }
  return 0;
}
