#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t) {
    int n;
    cin >> n;
    int a[n + 3];
    int el[n + 3];
    a[0] = 0;
    memset(el, 0, sizeof(el));
    for (int i = 1, h; i <= n; i++) {
      cin >> h;
      a[i] = h;
      a[i] += a[i - 1];
      el[h]++;
    }
    int spec = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (a[j] - a[i - 1] <= n && el[a[j] - a[i - 1]]) {
          spec += el[a[j] - a[i - 1]];
          el[a[j] - a[i - 1]] = 0;
        }
      }
    }
    cout << spec << endl;
    t--;
  }
}
