#include <bits/stdc++.h>
using namespace std;
int sum(int n) {
  int c = 0;
  while (n > 0) {
    c += n % 10;
    n /= 10;
  }
  return c;
}
void showarr(int arr[], int n) {
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}
int arr[8001], f[8001];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, t;
  cin >> t;
  while (t--) {
    int s, k, n, q, m = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      f[i + 1] = 0;
    }
    int ans = 0, cnt = 0;
    for (i = 0; i < n; i++) {
      cnt = arr[i];
      for (j = i + 1; j < n; j++) {
        cnt += arr[j];
        if (cnt > n) break;
        f[cnt] = 1;
      }
    }
    for (i = 0; i < n; i++) {
      if (f[arr[i]]) ans++;
    }
    cout << ans << "\n";
  }
}
