#include <bits/stdc++.h>
using namespace std;
int n, a[8005], preffixsum[8005], t, maxn, gone[8005], ans;
set<int> value;
map<int, int> tim;
int main() {
  scanf("%d", &t);
  preffixsum[0] = 0;
  while (t--) {
    scanf("%d", &n);
    maxn = -1;
    ans = 0;
    for (int i = 1; i <= n; i++) {
      tim[i] = 0;
      preffixsum[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      ++tim[a[i]];
      value.insert(a[i]);
      maxn = max(a[i], maxn);
      preffixsum[i] = preffixsum[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        int g = preffixsum[j] - preffixsum[i - 1];
        if (value.count(g)) {
          ans += tim[g];
          tim[g] = 0;
          value.erase(g);
        }
        if (value.empty()) break;
      }
    }
    value.clear();
    printf("%d\n", ans);
  }
}
