#include <bits/stdc++.h>
using namespace std;
int c[800001];
void solve() {
  int n;
  cin >> n;
  int a[n];
  memset(c, 0, sizeof(c));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  int b[n + 1];
  int x;
  b[0] = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  long long d = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if ((j - i) >= 2) {
        x = b[j] - b[i];
        if ((x >= 1) && (x <= n) && c[x] >= 1) {
          d += c[x];
          c[x] = 0;
        }
      }
    }
  }
  cout << d << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, n;
  cin >> t;
  while (t--) {
    solve();
  }
}
