#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> freq(n + 1);
    for (auto &x : a) {
      scanf("%d", &x);
      freq[x]++;
    }
    vector<bool> special(n + 1);
    for (int l = 0; l < n; l++) {
      int sum = a[l];
      for (int r = l + 1; r < n; r++) {
        sum += a[r];
        if (sum > n) break;
        special[sum] = freq[sum];
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (special[i]) {
        ans += freq[i];
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
