#include <bits/stdc++.h>
int a[8010], cnt[8010], sum[8010], vis[8010];
int main() {
  int t, n, i, j, b, tot;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) cnt[i] = 0, vis[i] = 0;
    for (i = 1; i <= n; i++)
      scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i], cnt[a[i]]++;
    tot = 0;
    for (i = 1; i <= n; i++)
      for (j = i + 1; j <= n; j++) {
        b = sum[j] - sum[i - 1];
        if (b <= n && cnt[b] && vis[b] == 0) tot += cnt[b], vis[b] = 1;
      }
    printf("%d\n", tot);
  }
  return 0;
}
