#include <bits/stdc++.h>
int a[8001];
int main() {
  int n, m, t, i, j;
  scanf("%d", &t);
  while (t--) {
    int ans = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0; i < n; i++) {
      int l = 0, sum = 0;
      for (j = 0; j < n; j++) {
        sum += a[j];
        while (sum > a[i] && l < j) {
          sum -= a[l];
          l++;
        }
        if (sum == a[i] && l < j) {
          ans++;
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
